w3resource

HTML code tag and element

1. HTML code element represents computer code.

2. By default, it is shown using the default font of the browser.

3. If you are enclosing computer code with code tags, make sure notations must be written using special characters. View the example given on this page.

Syntax

<code>text content </code> 

Category

HTML code element is a Phrase element.

Whether both start and end tags are required

Yes.

Can contain

HTML code element can contain inline elements.

Can reside within

HTML code element can reside within inline as well as block level elements.

Attributes

Attributes specific to this element

None.

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Example of using HTML code element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML em tag example - HTML tutorial | w3resource</title>
</head>
<body>
<p>This following text is computer code : <code>&lt;?php $x = w34; echo $x; ?&gt;</code></p>
</body>
</html>

Result

html code element

View this example in a separate browser window

HTML code tag example.

Pictorial presentation

html code element

Previous: HTML dfn tag and element
Next: HTML samp tag and element

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.