Warning:
This wiki has been archived and is now read-only.

Elements/code

From HTML Wiki
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>


HTML Reference

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