<code>

  • Revision slug: HTML/Element/code
  • Revision title: code
  • Revision id: 17452
  • Created:
  • Creator: xaky
  • Is current revision? No
  • Comment 24 words added, 1 words removed

Revision Content

The HTML Code Element (<code>) represents a fragment of computer code. By default, it is displayed in the browser's default monospace font.

Usage Context

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.10; HTML 4.01, section 9.2.1

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

   Regular text. <code>This is code.</code> Regular text.

Result

Regular text. This is code. Regular text.

Note

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

See Also

  • {{ HTMLElement("blockquote") }} element
  • {{ HTMLElement("q") }} element

{{ HTML:Element_Navigation() }}

{{ languages( { "pl": "pl/HTML/Element/code",  "fr": "fr/HTML/Element/code", "en": "en/HTML/Element/code"} ) }}

Revision Source

<p>The HTML Code Element (<span style="font-family: Courier New;">&lt;code&gt;</span>) represents a fragment of computer code. By default, it is displayed in the browser's default monospace font.</p>
<h2>Usage Context</h2>
<table class="standard-table"> <tbody> <tr> <td>Permitted content</td> <td><a href="/en/HTML/Content_categories#Phrasing_content" title="en/HTML/Content categories#Phrasing content">Phrasing content</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="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-code-element" title="http://www.w3.org/TR/html5/text-level-semantics.html#the-code-element">HTML5, section 4.6.10</a>; <a class=" external" href="http://www.w3.org/TR/html401/struct/text.html#h-9.2.1" title="http://www.w3.org/TR/html401/struct/text.html#h-9.2.1">HTML 4.01, section 9.2.1</a></td> </tr> </tbody>
</table>
<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="eval">   Regular text. &lt;code&gt;This is code.&lt;/code&gt; Regular text.
</pre>
<h4 name="Result">Result</h4>
<p>Regular text. <code>This is code.</code> Regular text.</p>
<h2>Note</h2>
<p>A CSS rule can be defined for the <code>code</code> selector to override the browser's default font face. Preferences set by the user might take precedence over the specified CSS.</p>
<h3 name="See_also">See Also</h3>
<ul> <li>{{ HTMLElement("blockquote") }} element</li> <li>{{ HTMLElement("q") }} element</li>
</ul>
<p>{{ HTML:Element_Navigation() }}</p>
<p>{{ languages( { "pl": "pl/HTML/Element/code",  "fr": "fr/HTML/Element/code", "en": "en/HTML/Element/code"} ) }}</p>
Revert to this revision