O'Reilly logo

Dynamic HTML: The Definitive Reference by Danny Goodman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

<CODE> — NN all IE all HTML all

Synopsis

<CODE>...</CODE>

End Tag: Required

The CODE element is one of a large group of elements that the HTML 4.0 recommendation calls phrase elements. Such elements assign structural meaning to a designated portion of the document. A CODE element is one that is used predominantly to display one or more inline characters representing computer code (program statements, variable names, keywords, and the like).

Browsers have free rein to determine how (or whether) to distinguish CODE element content from the rest of the BODY element. Both Navigator and Internet Explorer elect to render CODE element content in a monospace font, usually in a slightly smaller font size than the default body font (although it is not reduced in IE 4 for the Macintosh). This rendering can be overridden with a style sheet as you see fit.

White space (including carriage returns) are treated the same way in CODE element content as it is in the browser’s BODY element content. Line breaks must be manually inserted with BR elements. See also the PRE element for displaying preformatted text that observes all whitespace entered in the source code.

Example

Initialize a variable in JavaScript with the <CODE>var</CODE> keyword.

Object Model Reference

IE

[window.]document.all.elementID

Attributes

CLASS

ID

LANGUAGE

STYLE

TITLE

DIR

LANG

   

Event Handler Attributes

Handler

NN

IE

HTML

onClick

n/a

4

4

onDblClick

n/a

4

4

onDragStart

n/a

4

n/a

onHelp

n/a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required