Specifies a code sample. | HTML 2, 3.2, 4, 4.01, 5 |
HTML Syntax
<code>
...
</code>
NOTE: Both start and end tags are required.
The <code
> element displays a portion of text as a fragment of computer code.
The element is similar in function to the <kbd> and <samp> elements, that render text in the browser’s default fixed-width font.
code is used for inline formatting. For sections of code samples where block formatting is important, use the <pre> element to preserve the space characters and line breaks used in the code structure.
The <code>
element has no attribute of its own, but supports global attributes common to all HTML elements.
The following shows how the code element may be used.
<p>The <code>onLoad</code> attribute for the BODY tag lets authors define an action that
occurs when the document has finished loading.
<p>For example, <code>onLoad="function1 ( ); return false;"</code>.
<p>Notice that the <code>onLoad</code> statement should always return <code>false</code>.</p>
which would render on a Web page as
The onLoad
attribute for the BODY tag lets authors define an action that occurs when the document has finished loading.
For example, onLoad="function1 ( ); return false;"
.
Notice that the onLoad
statement should always return false
.
KBD PRE SAMP TT XMP