samp – program output

<samp>…</samp>

A sample of the output of a program or a computer: an error message, the result of a command in a terminal, text on a display. The browser displays it in a monospaced font (font-family: monospace; when the page does not set a font size, browsers shrink it from 16 px to 13 px).

  • Default display: display: inline
  • End tag: required
  • Content: phrasing content
  • Where it can be used: anywhere phrasing content is allowed
  • DOM interface: HTMLElement

Attributes

Only global attributes.

Examples

A program message and a terminal listing – the command entered in kbd, the output in samp:

<p>If <samp>File not found</samp> appears, check the path.</p>
<pre><samp>$ <kbd>php -v</kbd>
PHP 8.4.0 (cli)</samp></pre>
result

If File not found appears, check the path.

$ php -v
PHP 8.4.0 (cli)

Things to watch out for

  • Code written by a programmer is code, input from the user kbd – samp is only what the program prints.

Browser support

Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 1, Firefox 1, Safari 4. As of October 2026 (MDN browser-compat-data).

Related:
code – code
kbd – keyboard input
pre – preformatted text