Français

<samp>

Displaying what a program returned

  • HTML
  • accessibility
  • semantics

<samp> — Program output

The <samp> element represents sample output from a program, script, or terminal. It differs from <code> (source code) and <kbd> (user input).

When to use it

You want to show what a terminal displays, an error message, or the result of a command. Combine with <pre> for a multi-line block.

What you gain

Accessibility: same observation as <code> and <kbd>: screen readers do not treat <samp> differently. The value is structural: your code distinguishes what the program produced from what you wrote.

Code example

<p>The compiler returned: <samp>Build succeeded — 0 errors, 2 warnings.</samp></p>
 
<pre><samp>$ npm test
✓ 42 tests passed
✗ 1 test failed</samp></pre>

Further reading