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
language information and text direction
Title
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><?php $x = w34; echo $x; ?></code></p>
</body>
</html>
Result
View this example in a separate browser window
Pictorial presentation
Previous: HTML dfn tag and element
Next: HTML samp tag and element
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/code/HTML-code-tag-and-element.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics