HTML <code> Tag
Examples
Format text in a document:
<code>a piece of computer code print("Hello World")</code>
Try it Yourself »
Browser Support
![]()
All major browsers support the <code> tag.
Tag Definition and Usage
The <code> tag is a phrase tag used to define computer code text.
Tip:We are not against using this tag, but if you use it just to achieve a certain visual effect, we suggest you use CSS, which may produce richer effects.
All phrase tags:
| Tag | Description |
|---|---|
| <em> | Renders as emphasized text. |
| <strong> | Defines important text. |
| <dfn> | Defines a definition term. |
| <code> | Defines computer code text. |
| <samp> | Defines sample text. |
| <kbd> | Defines keyboard text. It indicates that the text is typed from a keyboard. It is often used in computer-related documents or manuals. |
| <var> | Defines a variable. You can use this tag together with the <pre> and <code> tags. |
Differences between HTML 4.01 and HTML5
None.
Global Attributes
The <code> tag supportsHTML Global Attributes。
Event Attributes
The <code> tag supportsHTML Event Attributes。
Related Articles
HTML Tutorial:HTML Text Formatting
Other Extensions