<code> (Code Listing)
This element indicates that the enclosed text is source code in a programming language. Usually it is rendered in a monospaced font.
Standard Syntax
<code
class="class name(s)"</code>
dir="ltr | rtl"
id="unique alphanumeric identifier"
lang="language code"
style="style information"
title="advisory text"
Attributes Defined by Internet Explorer
contenteditable="false | true | inherit" (5.5)
disabled="false | true" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
unselectable="on | off" (5.5)
Standard Events
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
Events Defined by Internet Explorer
onactivate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onblur, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresizeend, onresizestart, onselectstart, ontimeerror
Example
To increment a variable called count, use
<code> count++ </code>
Compatibility
HTML 2, 3.2, 4, 4.01, and XHTML 1.0, 1.1, Basic
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 1.1, 2, 3, 4, 4.5-4.8, 6, 7
Opera 4-7
Notes
This element is best for short code fragments because it does not preserve special indentation.
HTML 2.0 and 3.2 do not support any attributes for this element.
Internet Explorer documentation does not list accesskey nor tabindex for this element, but it is likely an oversight regardless of the value of the attribute for generally nonfocusable elements.