Skip to content
Tutorials Center
My learning

Topics

HTML Reference ยท Obsolete Elements

The <tt> element (obsolete)

The HTML <tt> element showed teletype or monospaced text and is obsolete. Learn which semantic element replaces it: <code>, <kbd>, <samp>, <var> or CSS.

The <tt> element (teletype text) displayed its content in a monospaced font, imitating the output of old teleprinter terminals. Authors used it for code, commands, file names and anything else that "looked technical".

Why it's obsolete

<tt> only described a font. HTML already had elements that describe the kind of technical text, so HTML5 made <tt> obsolete in their favor.

Browsers still render it in a monospace font, so old pages look the same.

Modern replacement

Choose the element that says what the text is:

  • <code> for code, file names and element names.
  • <kbd> for keys and input the user types.
  • <samp> for output from a program.
  • <var> for variables in math or code.
  • CSS font-family: monospace when no meaning applies.
tt before, semantic elements after

All of these are monospaced by default, so the look barely changes while the markup gains meaning.

Technical summary

Status Obsolete (non-conforming)
Replacement <code>, <kbd>, <samp>, <var> or CSS font-family: monospace
Still rendered by browsers Yes, in a monospace font