Syntax
<samp>Output text</samp> and <var>x</var>Examples
Program Output
Showing sample console output.
<p>Running the script prints: <samp>Build succeeded in 4.2s</samp></p>Mathematical Variable
Marking up a variable in an equation.
<p>The formula for area is <var>A</var> = <var>π</var><var>r</var><sup>2</sup>.</p>Combining kbd, samp, and var
Documenting a command-line interaction with proper semantic markup.
<p>Type <kbd>echo $PATH</kbd> and press Enter. The output will look like <samp>/usr/local/bin:/usr/bin</samp>, where <var>PATH</var> is your system's environment variable.</p>Best practices
- Use samp specifically for output a program actually produced, distinct from kbd (what the user types) and code (the code itself)
- Use var for variable names in math or pseudocode, not for arbitrary emphasized words
- Combine kbd, samp, code, and var together in technical documentation for precise, accessible meaning
- Do not reach for these elements purely for their default monospace/italic styling on unrelated text
Browser compatibility
Support applies to the named feature, not every attribute or behaviour in this article. Versions refer to browsers, not operating systems.
<samp>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
By 4 (possibly earlier) - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
By 3.2 (possibly earlier) - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- By 4 (possibly earlier)
Edge
- From 12
Opera
- From 15
Safari on iOS
- By 3.2 (possibly earlier)
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
<var>
Desktop
- Chrome
- Supported
From 1 - Firefox
- Supported
From 1 - Safari
- Supported
By 4 (possibly earlier) - Edge
- Supported
From 12 - Opera
- Supported
From 15
Mobile
- Safari on iOS
- Supported
By 3.2 (possibly earlier) - Chrome for Android
- Supported
From 18 - Firefox for Android
- Supported
From 4 - Samsung Internet
- Supported
From 1.0
MDN BCD record for this feature · MDN reference
Support history and limitations
Chrome
- From 1
Firefox
- From 1
Safari
- By 4 (possibly earlier)
Edge
- From 12
Opera
- From 15
Safari on iOS
- By 3.2 (possibly earlier)
Chrome for Android
- From 18
Firefox for Android
- From 4
Samsung Internet
- From 1.0
MDN BCD 8.1.5 · Dataset built 2026-10-08 · Mapping reviewed 2026-10-21. These dates are not individual browser-test or claim-verification dates. Unknown means the data does not establish support.