Home » HTML » HTML Code Tag

HTML Code Tag - Learn How to use Code tag in html

What is the code tag in HTML? - HTML <code> tag is used to represent computer code. It defines a piece of computer code. By default, HTML Code Tag is displayed in the browser's default monospace font.

Syntax for the code tag in html is:

<body>
<code>Contents... </code>
</body>     

Points about code tag:

  • Code tag in html is mainly used to display the code snippet into the web browser.
  • Using this html tag you can style its element and match it to the computer’s default text format.
  • By default the web browser use a monospace font family for displaying code tags content.

HTML Code Tag Example:


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Code Tag </title>
</head>
<body>
<em>Emphasized text</em><br>
<strong>Strong text</strong><br>
<code>A piece of computer code</code><br>
<samp>Sample output from a computer program</samp><br>
<kbd>Keyboard input</kbd><br>
<var>Variable</var>
</body>
</html>

Output

HTML Code Tag Examples Emphasized text
Strong text
A piece of computer code
Sample output from a computer program
Keyboard input
Variable

Attributes

Only the Global Attributes can be apply to the <code> tag. There are no such attributes that are specific to this html code tag.

Things you need to konw about before using code tag in html web page or doument

  • The HTML <code> tag is always found within the <body> tag.
  • By default the text within the html <code> tag is displayed in the monospace font on your browser.

The code tag in html supports almost all popular web browsers like Google Chrome, Android, Edge, Firefox, Opear, Safari and more..


HTML Code Tag

The HTML Code tag is a phrase tag that defines a piece of computer code.

Tags Description
<code> It defines a piece of computer code.
<kbd> It defines keyboard input.
<samp> It specifies a sample output from a computer program.
<pre> Defines preformatted text.
<dfn> It defines a definition term.
<var> It defines a variable.
<strong> It defines a important text.

Browser Support

Element
Microsoft Edge browser.png Edge
Chrome browser.png Chrome
Firefox browser.png Firefox
Opera browser.png Opera
safari browser.png Safari
<code>
Yes
Yes
Yes
Yes
Yes








Follow Us: