VOOZH about

URL: https://www.geeksforgeeks.org/html/html-code-tag/

⇱ HTML code Tag - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML code Tag

Last Updated : 28 May, 2026

The HTML <code> tag is a semantic element used to define a piece of computer code. When creating web pages, it's often necessary to display programming code, and the <code> tag makes it easy to do so.

The <code> tag is specifically designed to display computer output, such as code snippets, in a web browser. It's an essential element for developers, coders, and educators who need to share code online.

Syntax

<code> Contents... </code>

Features

  • Fixed formatting: The <code> tag is displayed with a fixed letter size, font, and spacing, making it easy to read and understand.
  • Monospace font: Web browsers use a monospace font family by default to display <code> tag content, ensuring that each character has the same width.
  • Computer default text format: The <code> tag styles its element to match the computer's default text format.

Nested Usage

<code> tag can also nest the within other HTML tags. For example, use it in a <pre> tag, which preserves whitespace and formatting:

Note: The browser support list may not be exhaustive, but the <code> tag is widely supported and used in web development.

Comment
Article Tags: