HTML <code> tag is employed to showcase snippets of programming code. This specific tag, classified as a phrase tag, is responsible for indicating a segment of code. It typically appears on the webpage in the browser's default monospace font, also referred to as fixed-width font.
List of HTML phrase tags
| Tag | Description |
|---|---|
<em> |
displays emphasized text |
<strong> |
displays important text |
<dfn> |
defines a definition term |
<code> |
defines a piece of computer code |
<samp> |
specifies a sample output from a computer program |
<kbd> |
defines keyboard input |
<var> |
defines a variable |
HTML phrase tags example including code tag
Example
<em>It is inside em tag.</em><br>
<strong>It is inside strong tag.</strong><br>
<dfn>It is inside dfn tag.</dfn><br>
<code>It is inside code tag.</code><br>
<samp>It is inside samp tag.</samp><br>
<kbd>It is inside kbd tag.</kbd><br>
<var>It is inside var tag.</var>
Output:
Output
It is inside code tag.
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
|---|---|---|---|---|---|
<code> |
Yes | Yes | Yes | Yes | Yes |