7.4. Monospaced Text

Another text formatting tag that has survived deprecation in XHTML is the teletype (<tt>), or monospaced, tag. This tag tells the user agent that text should be rendered in a monospaced font. You can use this tag to format reserved words in documentation, code listings, and so on. The following code shows an example of the teletype tag in use:

<p>Consider using the <tt>date()</tt> function for this purpose.</p>

This tag is named for the teletype terminals used with the first computers, which were capable of printing only in a monospaced font.

Again, the use of styles is preferred over individual in-line tags. If you need text rendered in a monospaced font, consider using styles instead of the <tt> tag.

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.