Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
The obsolete HTML Teletype Text element (<tt>
) creates inline text which is presented using the user agent's default monospace font face. This element was created for the purpose of rendering text as it would be displayed on a fixed-width display such as a teletype, text-only screen, or line printer.
The terms non-proportional, monotype, and monospace are used interchangeably and have the same general meaning: they describe a typeface whose characters are all the same number of pixels wide.
This element is obsolete, however. You should use the more semantically helpful <code>
, <kbd>
, <var>
, or <samp>
elements for inline text that needs to be presented in monospace type, or the <pre>
tag for content that should be presented as a separate block.
<span>
element, styling it as desired using CSS. The font-family
property is a good place to start.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 |
This element only includes the global attributes
This example uses <tt>
to show text entered into, and output by, a terminal application.
<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>
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:
tt { font-family: "Lucida Console", "Menlo", "Monaco", "Courier", monospace; }
<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>
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.
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.
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<tt>' in that specification. | Living Standard | |
HTML5 The definition of '<tt>' in that specification. | Recommendation | |
HTML 4.01 Specification The definition of '<tt>' in that specification. | Recommendation |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes1 | Yes | Yes | Yes |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | Opera Android | iOS Safari | Samsung Internet |
---|---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | Yes1 | Yes | Yes | ? |
1. Before Firefox 4, this element implemented the HTMLSpanElement
interface instead of the standard HTMLElement
interface.
<code>
, <var>
, <kbd>
, and <samp>
elements<pre>
element for displaying preformatted text blocks
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/tt