HTML <code> Tag

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The HTML <code> tag is used to enclose a section of text that represents computer code, such as programming code or markup language snippets. When this tag is applied to text, it typically renders the enclosed content in a monospaced or fixed-width font, making it stand out from the surrounding text and indicating that it should be interpreted as code rather than regular text. This tag is commonly used in documentation, tutorials, and programming-related web content to ensure that code examples are easily distinguishable and readable for the audience.

Properties

Permitted Parents
Any element that accepts phrasing content
Content
Inline and text
Start/End Tags
Start tag: required, End tag: required

Example

To create a new array, type the following: <code>var faq = new Array(3)</code>

Attributes

None

Global Attributes

The <code> tag also supports the Global Attributes in HTML5

Event Attributes

The <code> tag also supports the Event Attributes in HTML5

Browser Support

The following table will show you the current browser support for the HTML <code> tag.

Desktop
Edge Chrome Firefox Opera Safari
1211154
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
184143.214.4

Last updated by CSSPortal on: 30th September 2023