content logo

Learn HTML:

Html code tag

The HTML  tag represents a fragment of computer code.


The code fragment could be an XML element name, a filename, a computer program, or any other string that a computer would recognize.


Browsers usually display </code> content in a monospace font (also called a fixed-width or non-proportional font) such as Courier (unless style sheets have been used to specify a different font).




The  tag is written as </code> with the code fragment inserted between the start and end tags.

Displaying HTML Code


A common usage of the  is to display HTML code within a web page. To display HTML code, you need to use the correct HTML entities to ensure the HTML code is actually displayed (and not rendered) by the browser.


Specifically, you need to use &lt; in place of the less-than symbol (<) and &gt; in place of the greater-than symbol (>).

Multiple Lines


Multiple lines of code can be marked up by surrounding the  tags with <pre> tags.

Specifying the Computer Language

There is no formal way to specify the langauge of the computer code contained within the  tags. The HTML specification recommends specifying the language using the class attribute. For example, by using a prefix such as language- to the class name.


HTML Code Tag Definition


HTML Code Tag Usage


HTML Code Tag Examples