The tt html tag
In HTML the <tt> tag is a little unusual and is not often used due to its quirky appearance, in short the font mimics that of a Teletype machine. The <tt> tag is one of the original ways to format text and more recently CSS and other tags have reduced the importance of this tag. It is still a good tag when used correctly. When text is put between the opening and closing <tt> tag it is displayed as tt text. The <tt> tag can be used multiple times on a webpage and can be nested inside other tags for dramatic effect.
<tt>Some tt text</tt>
Any text between the opening and closing tag will be displayed as a large heading.
It is possible to style and add functionality to the <tt> tag, this is done by adding an attribute to after the tt in the opening <tt> tag.
Attributes allowed for the <tt>tag include :-class, dir, id, lang, style and title.
In most cases class and id are used and its basic usage is shown below
<tt id=”header”>Some tt text</tt>
With all attributes there is a space after the initial b then the attribute name, then an equal’s sign and the identifier of the attribute in double quotes.
Both id and class attributes refer to CSS styling of the element and is either stored in the <head> of the webpage on in an external file.
With id this usually refers to a single instance on a page where as class usually refers to a repeating element on a page, it is for this reason for the <tt> tag the class attribute is nearly always used over the id attribute although in practice it makes no difference.
The attribute style allows you to include css style information for a single <tt> tag.
The dir attribute allows for left reading and right reading text, lang allows you to specify a language for the tag and title allows you to include extra information for a tag.
<tt>Some tt text</tt> – basic usage example.
<tt id=”header”>Some tt text</tt> – tt text which is styled by the id header.
<tt class=”headerclass”> Some tt text </tt> – tt text which is styled by the class headerclass.
<tt id =”header” class=”headerclass”> Some tt text </tt> – tt text which is styled by the class headerclass and the id header.
<tt style=”color:#F00″>Some tt text</tt> – tt text which has a custom colour of red.
<tt dir=”rtl”>Some tt text</tt> – tt text where the text reads from right to left.
<tt lang=”uk”>Some tt text</tt> – tt text where the language has been tagged as UK.
<tt title=”ptitle”>Some tt text</tt> – tt text where the tag has been titled ptitle.
Touching on just the surface of the <tt> HTML tag it is easy to see how versatile it is. To take full advantage of it an understanding of CSS is an advantage.