HTML <samp> Tag

Topic: HTML5 Tags Reference« Prev|Next »

Description

The <samp> (short for sample) tag specifies text as sample code. It typically represents sample output from a computer programs, scripts, etc.

The following table summarizes the usages context and the version history of this tag.

Placement: Inline
Content: Inline and text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 2, 3.2, 4, 4.01, 5
 

Note:By default, browsers display the sample text in a monospace font, such as "Courier New", but you can override this style using the CSS font-family property.


Syntax

The basic syntax of the <samp> tag is given with:

HTML / XHTML: <samp> ... </samp>

The example below shows the <samp> tag in action.

  • <p>If the browser display an error message such as
    <samp>HTTP 404 - File not found</samp>,
    you may simply have typed the incorrect url address.</p>

Tag-Specific Attributes

The <samp> tag doesn't have any specific attribute.


Global Attributes

Like all other HTML tags, the <samp> tag supports the global attributes in HTML5.


Event Attributes

The <samp> tag also supports the event attributes in HTML5.


Browser Compatibility

The <samp> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Text Formatting.

Related tag: <code>.

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.