HTML <code> tag

Use of <code> tag

The <code> tag is a phrase tag. It is used to define enclosed text as computer code. It has special use to display programming codes, functions etc.
By default, browsers set the font-family of <code> element as monospace.
Type: Inline Element

Example of <code> tag

<code> x + y = 10</code>

Supported Browsers

Tag Chrome browser Internet explorer browser Firefox browser Safari browser Opera browser
<code> Yes Yes Yes Yes Yes

Full Code Example

<!DOCTYPE html>
x = 10,
y = 20, then
x + y = 30


x = 10, y = 20, then x + y = 30

By Default, <code> tag do not preserve line space and line break. If you want to preserve it, write them within <pre> tag.

      x = 10,
      y = 20, then
      x + y = 30

Result will look like this:

      x = 10,
      y = 20, then
      x + y = 30

More Reference

<code> tag is a phrase tag.

Default CSS property of <code> tag

code {
font-family: monospace;

Other related phrase tag

Tag Notes
em It defines emphasized texts.
kbd It defines a users input or sometimes voice command.
samp It defines an output from a system.
strong It defines strong texts.
var It defines a variable.