English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
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.
IEFirefoxOperaChromeSafari
All mainstream browsers support the <code> 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:
Tag | Description |
---|---|
<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. |
None.
Support for <code> tag Global Attributes of HTML.
Support for <code> tag HTML Event Attributes.
HTML Tutorial:HTML Text Formatting