What is the code tag in HTML?

The code tag in HTML is used to highlight a text segment as a code region. Text within the code tag appears in monospace font.

The code tag does not make a text region executable. It only changes its appearance.

The illustration below shows how the code tag works in HTML:

How code tag works in HTML

Syntax

The syntax of the code tag is as follows:

<code> Write code here </code>

We begin by opening the tags using the <> symbol. In between, we write the keyword code. We then close the tags using the </> symbol. Once again, we will place the name of our tag between <> and after the / symbol. Any text in-between will be displayed in a different font.

Example

The code snippet below shows how we can use the code tag in HTML:

  • HTML

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved