HTML code Tag

HTML <code> Tag: The HTML<code> tag describes a piece of computer code. And it is one of the phrase tags. While the tag is displayed in the browsers with default monospace font. During the creation of web pages sometimes there is a need to display computer programming code. It could be done by any basic heading tag of HTML but HTML provides a separated tag which is <code>.

HTML <code> Tag

The HTML<code> tag supports both the global and the event attributes. The HTML code tag is a specific type of text which represent computer output. HTML provides many methods for text-formatting but <code> tag is displayed with fixed letter size, font, and spacing.

Syntax: <code> Text </code>



Browser compatibility

The HTML<code> tag is supported by different type of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • InternetExplorer.

Example:

<!DOCTYPE html>
<html>
<body>
<code>This is a text</code><br>
</body>
</html>

Output:

This is a text

Tags that are supported by the <code> tag

Tag Description
em Renders as emphasized text
strong Specifies the important text
code Defines a piece of computer code
samp Specifies sample output from a computer program
kbd Specifies keyboard input
var Specifies a variable