HTML Reference ยท Inline Text
The <samp> element
Reference for the HTML <samp> element: sample output from a program or system, how it combines with <kbd> and <pre>, examples and technical details.
The <samp> element marks output from a computer program or system: an error message, a terminal response, a status line from a device. It tells readers (and tools) that this text was produced by software rather than written by a person or typed by the user. Browsers show it in a monospace font by default.
<p>If the upload fails, you will see <samp>Error 413: file too large</samp>.</p>
Try it
Inside the terminal block, <kbd> marks what the user typed while the surrounding <samp> marks what the system printed. In the last paragraph, <kbd><samp>โฆ</samp></kbd> means "the user chose an option that the system displayed".
Attributes
This element has no attributes of its own. It accepts the global attributes.
Usage notes
<samp>vs<code>vs<kbd>.<code>is source code,<kbd>is input the user enters, and<samp>is what the computer says back.- Multi-line output. Wrap
<samp>in<pre>to keep line breaks and spacing, as in a terminal session. - Nesting.
<kbd>inside<samp>marks input echoed by the system (like a typed command in a transcript).<samp>inside<kbd>marks the user selecting text that appeared on screen, such as a menu item. - Not for styling. If you only want monospace text, use CSS
font-family: monospacerather than borrowing<samp>. - Accessibility. Screen readers usually read
<samp>as ordinary text, so make sure the surrounding sentence says that it is a message or output.
Technical summary
| Content categories | Flow content, phrasing content, palpable content |
| Permitted content | Phrasing content |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | Any element that accepts phrasing content |
| Implicit ARIA role | generic |
| DOM interface | HTMLElement |
| Default display | inline (in a monospace font) |
Browser support
Supported in every browser.
Related
<code>โ a fragment of computer code<kbd>โ user input<var>โ a variable<pre>โ preformatted text- Lesson: Code, Keyboard Input and Program Output