References

Beginner-friendly references for web development, with live, editable examples.

The HTML <samp> tag

Element All modern browsers Updated
Quick answer

The HTML <samp> element represents sample output from a computer program or system — an error message, console output — typically shown in a monospace font. It is distinct from <code> (source code) and <kbd> (user input).

Overview

The <samp> element marks text that is quoted output from a program or computer system — what a terminal prints, an error message, a status line, or any sample of machine-generated output. Browsers render it in a monospace font.

It completes a small family of technical elements: <code> is the source code, <kbd> is what the user types, and <samp> is what the system outputs in response. Using the right one makes documentation and tutorials clearer to both readers and assistive technology.

Syntax

<p>The program printed <samp>File not found</samp>.</p>

Example

Live example
<p>If you see <samp>404 Not Found</samp>, the page does not exist.</p>

Best practices

  • Use <samp> for program or system output — terminal text, error and status messages.
  • Pair it with <kbd> (user input) and <code> (source) in tutorials.
  • Nest a <kbd> inside it to show input echoed back within output.
  • Style it with CSS if the monospace default does not match your design.

Frequently asked questions

What is the samp element for?
To mark up sample output from a program or computer system — such as terminal output or an error message.
What is the difference between samp and code?
<samp> is program output; <code> is the source code itself.
When would I use samp instead of kbd?
Use <samp> for what the computer outputs and <kbd> for what the user types in.
Does samp change the appearance of text?
By default it renders in a monospace font, but you can restyle it with CSS.