Content categories | Flow content, phrasing content, palpable content. |
---|---|
Permitted content | Phrasing content. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts phrasing content. |
Permitted ARIA roles | Any |
DOM interface |
HTMLElement Up to Gecko 1.9.2 (Firefox 4) inclusive, Firefox implements the HTMLSpanElement interface for this element. |
This element only includes the global attributes.
A paragraph of text that includes code:
<p>The function <code>selectAll()</code> highlights all the text in the input field so the user can, for example, copy or delete the text.</p>
The output generated by this HTML looks like this:
To represent multiple lines of code, wrap the <code>
element within a <pre>
element. The <code>
element by itself only represents a single phrase of code or line of code.
A CSS rule can be defined for the code
selector to override the browser's default font face. Preferences set by the user might take precedence over the specified CSS.
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<code>' in that specification. | Living Standard | |
HTML5 The definition of '<code>' in that specification. | Recommendation | |
HTML 4.01 Specification The definition of '<code>' in that specification. | Recommendation |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 1 | Yes | 1 | Yes | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code