The
<tt>tag in HTML stands for “teletype text.”
It was used to display text in a monospaced (fixed-width) font, resembling the output of old teletype machines.
This tag is deprecated in HTML5, and developers should use CSS or the<code>tag instead.
Syntax
<tt>Monospaced text</tt>Attributes
| Attribute | Description |
|---|---|
| None | The <tt> tag does not have any specific attributes. |
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TT Tag Example</title>
</head>
<body>
<h2>Deprecated <tt> Tag Example</h2>
<p>Normal text: Hello, World!</p>
<p>Teletype text using <tt>: <tt>Hello, World!</tt></p>
<p><strong>Modern alternative:</strong> Use CSS or <code> tag:</p>
<code style="font-family: monospace;">Hello, World!</code>
</body>
</html>Output
Browser Output
The text inside the <tt> tag appears in a monospaced (typewriter-style) font.
Please use our TryIt Editor to see the effect.
Browser Support
Chrome | Firefox | Edge | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes | ✅Yes |
All major browsers support <tt> tag.
Notes
- The
<tt>tag is obsolete in HTML5. - Use CSS for styling monospaced text instead, for example:
p { font-family: monospace; }The <code> tag is semantically appropriate for displaying computer code or command-line text.
Conclusion
The <tt> tag once displayed text in a fixed-width font but is now deprecated.
Use CSS or semantic tags like <code> for modern and standards-compliant web development.