<code>
The <code> HTML element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code. By default, the content text is displayed using the user agent's default monospace font.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 1 | 12 | 1 | ≤4 | 18 | ≤3.2 | |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
HTML
<p><code>console.log()</code> You can generate debug output.</p>
<pre><code>function greet(name) {
return `Hello, ${name}!`;
}</code></pre> Live demo
inlineco-d
Code element in textmiddle to co-d fill.functionname or variablename. Display to.
PreviewFullscreen
Use cases
-
Using <code>
The <code> HTML element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code.
Cautions
- May not be supported in older browsers.
Accessibility
- Verify how this element is announced by screen readers.