asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > CODE Element

<code> Element


Specifies a code sample.HTML 2, 3.2, 4, 4.01, 5

HTML Syntax

NOTE: Both start and end tags are required.

Remarks

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.

Attributes

The <code> element has no attribute of its own, but supports global attributes common to all HTML elements.

Example

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.

External References

See Also

KBD   PRE   SAMP   TT   XMP


Need a break ?
Suggested Reading

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph.

If you have any question, comment or suggestion,
please send us a note