English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <code> Tag

The HTML <code> tag defines a fragment of computer code within an HTML document. The <code> element presents a block of computer code. By default, it is displayed in the browser's default monospace font.

Online Example

Format text in the document:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic Tutorial Website(oldtoolbag.com)</title> 
</head>
<body>
<code>Computer code goes here</code>
</body>
</html>
Test and see ‹/›

In this HTML5In the document example, we created a <code> tag containing the text 'Computer code goes here', which will be displayed in the browser's default monospace font.

Browser Compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <code> tag.

Definition and Usage of the Tag

The <code> element is located within the <body> tag.

The <code> tag is a phrase tag used to define computer code text.

Text within <code> tags is displayed in the browser's default monospaced font.

Tip: We are not against using this tag, but if you just use it to achieve a certain visual effect, we recommend using CSS, which may achieve richer effects.

All phrase tags:

TagDescription
<em>Presented as emphasized text.
<strong>Define important text.
<dfn>Define a definition item.
<code>Define computer code text.
<samp>Define sample text.
<kbd>Define keyboard text. It indicates that the text is typed from the keyboard. It is often used in documents or manuals related to computers.
<var>Define variables. You can use this tag in conjunction with <pre> and <code> tags.

HTML 4.01 and HTML5Differences Between

None.

Global Attributes

Support for <code> tag Global Attributes of HTML.

Event Attributes

Support for <code> tag HTML Event Attributes.

Related Articles

HTML Tutorial:HTML Text Formatting