English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML tag大全

HTML: <tt> tag

HTML telegraph text element ( <tt>) generates an inline element, displaying text with the browser's built-in monotype font. This element is used for text formatting, making it display in a fixed-width, similar to telegrams. Using the <code> element to display fixed-width text may be more common.

Online examples

Demonstration of using tt:

!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML tt tag usage (Basic Tutorial Website oldtoolbag.com)</title>
</head>
<body>
<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>
</body>
</html>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers support the <tt> tag.

Definition and usage instructions

HTML5 Does not support <tt> t tag. Use CSS instead.

The <tt> tag defines typewriter text.

Tips and Notes

Tip:Use CSS to specify the text type in the document.

CSS specifications can define tt selectors to override the default browser font. Preferences set using CSS may take precedence over specified CSS.

Although this element is not in the HTML 4.01 Abandoned in the HTML specification, not recommended for use to support style sheets.

HTML 4.01 And HTML5Differences between

HTML5 Does not support <tt> tag. HTML 4.01 Supports <tt> tag.

Standard Attributes

In HTML 4.01 The <tt> tag supports the following standard attributes:

AttributeValueDescription
classclassnameClass name of the specified element
dirrtl
ltr
Text direction within the specified element
ididUnique id of the specified element
langlanguage_codeLanguage code for the content of the specified element
stylestyle_definitionSpecify the inline style of an element
titletextSpecify additional information about an element
xml:langlanguage_codeSpecify the language code for the content of an XHTML document element

For a complete description, please visitStandard Attributes.

Event Attributes

In HTML 4.01 In, the <tt> tag supports the following event attributes:

AttributeValueDescription
onclickscriptExecute script when the mouse is clicked
ondblclickscriptExecute script when the mouse is double-clicked
onmousedownscriptExecute script when the mouse button is pressed
onmousemovescriptExecute script when the mouse pointer moves
onmouseoutscriptExecute script when the mouse pointer moves out of an element
onmouseoverscriptExecute script when the mouse pointer hovers over an element
onmouseupscriptExecute script when the mouse button is released
onkeydownscriptExecute script when the keyboard is pressed
onkeypressscriptExecute script when the keyboard is pressed and then released
onkeyupscriptExecute script when the keyboard is released

For a complete description, please visitEvent Attributes.