HTML5 <samp> Tag

The HTML <samp> tag is used to represent an element intended to identify sample output from a computer program. It is usually displayed in the browser’s default monotype font (such as Lucida Console).

The only content permitted inside this element is phrasing content. Both the starting and ending tag are mandatory for this element. The parent of the <samp> tag can be any element that accepts phrasing content.

A CSS rule can be defined for the samp selector to override the browser’s default font face. Preferences set by the user might take precedence over the specified CSS.

The following style is applied to this element by default:

samp {
  font-family: monospace;
}

Here is an example of using this tag:

<p>The diet-tracking app said: <samp>You're not eating your veggies</samp> and that was true.</p>


<p>The computer said <samp>Too much cheese in tray two</samp> but I didn't know what that meant.</p>

Attributes

This element only accepts global attributes.

Examples

See the Pen HTML samp Tag by Tutorialio (@tutorialio) on CodePen.

Further Reading

  1. Read more about the HTML <samp> element on MDN.
  2. You can also read the HTML <samp> tag reference on W3C.

Reader Comments

1. You can register or login to post a comment. Asking readers to register improves the quality of discussion.

2. As a registered user, you will also get to access features like choosing between a light and dark theme or anything else that we might implement in future.

Follow Us For Updates

FacebookTwitterGoogle+
Go To Top