HTML <code> Tag

Description

The <code> HTML element is designed to display one or more lines of text, which is program code. This includes variable names, keywords, function texts, etc. Browsers typically display the contents of the <code> container as reduced-width monospaced text.

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

Desktop
Explorer Edge Chrome Firefox Opera Safari
YesYes11YesYes
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4YesYesYes