<tt>: The Teletype Text element - HTML | MDN
Attributes
This element only includes the global attributes
Examples
Basic example
This example uses <tt> to show text entered into, and output by, a terminal application.
html
<p>
Enter the following at the telnet command prompt:
<code>set localecho</code><br />
The telnet client should display: <tt>Local Echo is on</tt>
</p>
Result
Overriding the default font
You can override the browser's default font—if the browser permits you to do so, which it isn't required to do—using CSS:
CSS
css
tt {
font-family: "Lucida Console", "Menlo", "Monaco", "Courier New", monospace;
}
HTML
html
<p>
Enter the following at the telnet command prompt:
<code>set localecho</code><br />
The telnet client should display: <tt>Local Echo is on</tt>
</p>
Result
Usage notes
The <tt> element is, by default, rendered using the browser's default non-proportional font. You can override this using CSS by creating a rule using the tt selector, as seen in the example Overriding the default font above.
Note: User-configured changes to the default monospace font setting may take precedence over your CSS.
Although this element wasn't officially deprecated in HTML 4.01, its use was discouraged in favor of the semantic elements and/or CSS. The <tt> element is obsolete in HTML 5.
Technical summary
| Content categories | Flow content, phrasing content, palpable content. |
|---|---|
| Permitted content | Phrasing content. |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents | Any element that accepts phrasing content. |
| Permitted ARIA roles | Any |
| DOM interface | HTMLElement |
Specifications
| Specification |
|---|
| HTML # tt |