CSS Portal

HTML <samp> Tag

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The <samp> tag in HTML is used to represent sample output from a computer program or system. Essentially, it is meant to display the exact text that a program would output, such as the results of a command-line interface, error messages, or any other machine-generated text. It is a semantic element, which means it conveys meaning about the content, not just how it looks, helping both developers and assistive technologies understand that the enclosed text is sample output.

By default, browsers render <samp> text using the monospace (fixed-width) font, which is typical for code, terminal output, and other preformatted program outputs. This makes it easier for users to distinguish sample output from normal text and preserves the alignment and spacing of characters, which can be important when showing things like tables, formatted logs, or ASCII art.

The <samp> element is inline, meaning it can appear within paragraphs or alongside other text without forcing line breaks. It is commonly used together with other elements like <code> or <kbd> to provide a complete context for code snippets, user input, and program output. For example, <kbd> is used for user input, <code> for code snippets, and <samp> for the resulting output.

Using <samp> not only improves the readability of technical documentation and tutorials but also enhances accessibility, as screen readers can announce the content appropriately as sample output rather than ordinary text.

Properties

Permitted Parents
Any element that accepts phrasing content
Content
Inline and text
Start/End Tags
Start tag: required, End tag: required

Example

You will see <samp>END PROGRAM</samp> after 
it stops scrolling.
If it never stops, send the <samp>STOP</samp>
command to the program.

Attributes

None

Global Attributes

The <samp> tag also supports the Global Attributes in HTML5

Event Attributes

The <samp> tag also supports the Event Attributes in HTML5

Browser Support

The following information will show you the current browser support for the HTML <samp> tag. Hover over a browser icon to see the version that first introduced support for this HTML tag.

This tag is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 26th December 2025

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!