Expand your HTML skills through an MDN Fellowship - Apply by April 1 http://mzl.la/MDNFellowship

mozilla

Revision 22479 of <samp>

  • Revision slug: HTML/Element/samp
  • Revision title: samp
  • Revision id: 22479
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment 1 words added, 2 words removed

Revision Content

Summary

The HTML Sample Text Element (<samp>) produces an inline element displayed in the browser's default monotype font (Lucida Console). This element was intended to identify sample output from a computer program.

Usage context

Content categories Flow content, phrasing content
Permitted content Phrasing content
Tag omission None, must have both a start tag and an end tag.
Permitted parent elements Any element that accepts phrasing content.
Normative document HTML5, section 4.6.13; HTML 4.01, section 9.2.1

Attributes

Like all other HTML elements, this element supports the global attributes.

DOM Interface

This element implements the HTMLElement interface.

Implementation note: up to Gecko 1.9.2 inclusive, Firefox implements the HTMLSpanElement interface for this element.

Example

<p>Regular text. <samp>This is sample text.</samp> Regular text.</p>

Result

Regular text. <samp>This is sample text.</samp> Regular text.

(This example appears not to work due to restrictions in the wiki software, but in real web pages it should be fine!)

Note

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.

See also

{{ HTML:Element_Navigation() }}

{{ languages( { "pl": "pl/HTML/Element/samp" } ) }}

Revision Source

<h2>Summary</h2>
<p>The HTML Sample Text Element (<span style="font-family: Courier New;">&lt;samp&gt;</span>) produces an inline element displayed in the browser's default monotype font (Lucida Console). This element was intended to identify sample output from a computer program.</p>
<h2>Usage context</h2>
<table class="standard-table"> <tbody> <tr> <td>Content categories</td> <td><a href="/en/HTML/Content_categories#Flow_content" title="en/HTML/Content categories#Flow content">Flow content</a>, <a href="/en/HTML/Content_categories#Phrasing_content" title="en/HTML/Content categories#Phrasing content">phrasing content</a><a href="/en/HTML/Content_categories#form-associated_content" title="en/HTML/Content categories#form-associated content"><br> </a></td> </tr> <tr> <td>Permitted content</td> <td><a href="/en/HTML/Content_categories#Phrasing_content" title="en/HTML/Content categories#Phrasing content">Phrasing content</a><a href="/en/HTML/Content_categories#form-associated_content" title="en/HTML/Content categories#form-associated content"><br> </a></td> </tr> <tr> <td>Tag omission</td> <td>None, must have both a start tag and an end tag.</td> </tr> <tr> <td>Permitted parent elements</td> <td>Any element that accepts <a href="/en/HTML/Content_categories#Phrasing_content" title="https://developer.mozilla.org/en/HTML/Content_categories#Phrasing_content">phrasing content</a>.</td> </tr> <tr> <td>Normative document</td> <td><a class="external" href="http://www.w3.org/TR/html5/text-level-semantics.html#the-samp-element" title="http://www.w3.org/TR/html5/text-level-semantics.html#the-samp-elementt">HTML5, section 4.6.13</a>; <a class="external" href="http://www.w3.org/TR/html401/struct/text.html#h-9.2.1" title=" title=">HTML 4.01, section 9.2.1</a></td> </tr> </tbody>
</table>
<h2>Attributes</h2>
<p>Like all other HTML elements, this element supports the <a href="/en/HTML/Global_attributes" title="en/HTML/Global attributes">global attributes</a>.</p>
<h2>DOM Interface</h2>
<p>This element implements the <code><a href="/en/DOM/element" title="en/DOM/element">HTMLElement</a></code> interface.</p>
<div class="note">
<p><strong>Implementation note: </strong>up to Gecko 1.9.2 inclusive, Firefox implements the <a href="/en/DOM/span" title="en/DOM/span"><span style="font-family: Courier New;">HTMLSpanElement</span></a> interface for this element.</p>
</div>
<h2>Example</h2>
<pre class="brush: html">&lt;p&gt;Regular text. &lt;samp&gt;This is sample text.&lt;/samp&gt; Regular text.&lt;/p&gt;
</pre>
<h2>Result</h2>
<p>Regular text. &lt;samp&gt;This is sample text.&lt;/samp&gt; Regular text.</p>
<p>(This example appears not to work due to restrictions in the wiki software, but in real web pages it should be fine!)</p>
<h2>Note</h2>
<p>A CSS rule can be defined for the <code>samp</code> selector to override the browser's default font face. Preferences set by the user might take precedence over the specified CSS.</p>
<h2>See also</h2>
<ul> <li><a href="/en/HTML/Element/code" title="en/HTML/Element/code">HTML Code Element</a></li> <li>HTML 4.01 Specification: <a class="external" href="http://www.w3.org/TR/html4/struct/text.html#h-9.2.1">Phrase Elements</a></li>
</ul>
<p>{{ HTML:Element_Navigation() }}</p>
<p>{{ languages( { "pl": "pl/HTML/Element/samp" } ) }}</p>
Revert to this revision