HTML <samp> Element

The HTML <samp> element represents sample output produced by a computer program, command, system, or other computing process.

Syntax

<p>The program displays: <samp>File saved successfully.</samp></p>

The <samp> element requires both an opening and closing tag. The text between the tags represents output that would be produced by a computer or program.

Attributes

The <samp> element supports the global HTML attributes. It does not have any element-specific attributes.

Example

This example uses the <samp> element to identify a message that represents output from a computer program.

Play in Editor

Usage Notes

Use the <samp> element when displaying text that represents output generated by software, a command-line program, a computer system, or another computing process.

Browsers normally display <samp> text using a monospace font, although its appearance can be changed with CSS without changing the meaning of the element.

Use the <code> element for computer code rather than program output. Use the <kbd> element when identifying text or commands that a user is expected to enter.

The <samp> element can be placed inside a <pre> element when the output contains multiple lines and its spacing or line breaks should be preserved.

Accessibility

Using the <samp> element gives computer-generated output semantic meaning instead of identifying it only through visual formatting such as a monospace font.

Provide enough surrounding text for users to understand what produced the output and what the message means. Do not rely only on font style, color, or other visual differences to distinguish program output from instructions or user input.

Browser Support

Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.

For detailed browser compatibility information, see Can I Use: HTML <samp> Element .

The <samp> element is closely related to the <code> element for computer code, the <kbd> element for user input, and the <pre> element for preformatted text.

Specifications

HTML Living Standard: The <samp> Element