The <tt> (teletype) element once showed inline monospace text, like a fixed-width terminal or line printer. It was presentational only.
Learn it only to recognize legacy pages. For new work, pick a semantic element — <code>, <kbd>, <samp>, <var> — or a block with <pre>. If you only need the look, style with CSS font-family (MDN).
Deprecated / Obsolete.
Do not use <tt> in new HTML. MDN: avoid this feature; it is obsolete in HTML5.
Still rendered in many browsers.
Legacy support exists for old documents, but that is not permission to ship new <tt> markup.
Syntax
HTML Syntax
syntax.html
<tt>monospace text</tt>
Modern equivalents:<code>…</code>, <kbd>…</kbd>, <samp>…</samp>, or <span style="font-family: monospace">…</span> (prefer a stylesheet class over inline style).
Reference
Attributes
<tt> had no element-specific attributes — only globals. Choose a modern replacement by meaning:
One line: recognize <tt>, replace it with semantic monospace tags or CSS.
UA style
Default CSS Settings
Typical user-agent styling for tt (and common modern replacements):
default.css
tt {
font-family: monospace;
}
/* Prefer these in modern stylesheets */
code, kbd, samp {
font-family: monospace;
}
Prefer styling code / kbd / samp. Leave tt rules only while cleaning legacy CSS.
Frequently Asked Questions
Historically, tt (teletype) showed inline text in the browser’s default monospace font, like a fixed-width terminal. It is obsolete in HTML5 and should not be used in new pages.
No for authors. MDN marks tt Deprecated; HTML5 lists it as obsolete. Browsers may still render it for old content, but new markup should use semantic elements or CSS.
Prefer code for source, kbd for user input, samp for sample output, var for variables, or pre for multi-line blocks. If you only need monospace look with no better semantics, use a span (or similar) styled with font-family: monospace.
No. Only global attributes. Apply class or style on modern replacements instead.
Usually not visually — many browsers still show monospace for tt. Treat that as legacy recognition, not permission to keep shipping tt.
It was presentational only. HTML prefers semantic monospace elements (code, kbd, samp, var) or CSS for pure styling.