The CODE Tag

The HTML CODE Tag

< Previous | HTML 4.01 Tags | XHTML 1.0 Elements | Next >

Free HTML Class | HTML Validators

CODE Description:

The CODE tag indicates that the enclosed text is computer code or programming code.

The CODE tag is a semantic tag that gives the enclosed text a specific meaning for the computer. These types of tags are used more for style and to markup your text more meaningfully than for layout or design.

CODE Web Browser Support:

  • AvantGo Windows CE
  • Chrome 1, 2, 3, 4, 5
  • Firefox 1, 2, 3
  • Internet Explorer 2, 3, 4, 5, 6, 7, 8
  • Netscape 2, 3, 4, 6, 7, 8
  • Opera 3, 4, 5, 6, 7, 8, 9, 10
  • Safari 1, 2, 3, 4, 5
  • WebTV/MSN TV

HTML Versions

  • HTML 3.2, 4.0
  • HTML5
  • XHTML 1.0

CODE Attributes:

Global attributes and event attributes.

CODE End Tag:

</code> REQUIRED

CODE Contents:

CDATA Usually text. The following tags are valid within the CODE tag:
a, abbr, acronym, applet, b, basefont, bdo, big, br, button, cite, code, dfn, em, font, i, iframe, img, input, kbd, label, map, object, q, s, samp, script, select, small, span, strike, strong, sub, sup, tt, u, var

CODE Valid Context:

The CODE tag is valid within the following tags:
a, abbr, acronym, address, applet, b, bdo, big, blockquote, body, button, caption, center, cite, code, dd, del, dfn, div, dt, em, fieldset, font, form, h1, h2, h3, h4, h5, h6, i, iframe, ins, kbd, label, legend, li, noframes, noscript, object, p, q, s, samp, small, span, strike, strong, sub, sup, td, th, tt, u, var

CODE Usage:

standard code example

<p>
  This is a typical HTML header:
  <code>
    &lt;html&gt;
      &lt;head&gt;
        &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
  </code>
</p>

CODE Special Notes:

  • Most browsers display the code tag in a monospace font.
  • You should not use this tag to get monospaced text, if you need that, you should use the font-family style property.
  • Don”t confuse the CODE tag with the CODE attribute of the APPLET tag.

More CODE Information:

  • The code Attribute

< Previous | HTML 4.01 Tags | XHTML 1.0 Elements | Next >