HTML/Elements/code

From W3C Wiki
< HTML‎ | Elements
Jump to: navigation, search

<code>

The <code> element represents a fragment of computer code.

Point

  • For example of computer code:
    • XML element name
    • filename
    • computer program

etc. Any other string that a computer would recognize.

HTML Attributes

See global attributes.


Examples

Example A

The following example shows how a block of code could be marked up using the pre and code elements [try it]:

<pre>
  <code>
  function Panel(element, canClose, closeHandler) {
    this.element = element;
    this.canClose = canClose;
    this.closeHandler = function () { if (closeHandler) closeHandler() };
  }
  </code>
</pre>

Code01.png

HTML Reference

The HTML5 specification defines the <code> element in 4.6.11 The code element.