From Web Education Community Group
< HTML‎ | Elements
Revision as of 16:42, 22 November 2011 by Hiroki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


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


  • 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.


Example A

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

  function Panel(element, canClose, closeHandler) {
    this.element = element;
    this.canClose = canClose;
    this.closeHandler = function () { if (closeHandler) closeHandler() };


HTML Reference

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