3.3 Deprecated Tags
In recent years there has been a big move towards using CSS (Cascading Stylesheets), which is another language, for styling HTML documents. As a result most attributes for tags are now specified as CSS properties, which will be dealt with in the CSS Tutorial. We needn't worry about this just now, but as a result many tags that were once used in HTML pages to define these attributes are now deprecated and shouldn't be used any more (especially in XHTML).
As we've just seen, one classic example of this is the <font> tag. This would have once been used to define attributes for text such as font size, colour and face, like this:
<p><font size="2" color="blue" face="Verdana">Content text</font></p>
Notice how bulky this old fashioned HTML code is compared to the following:
<p>Content text</p>
Here all we need in the HTML page is the paragraph tag <p>. This is far lighter, because any attributes for the <p> tag can be defined elsewhere, as properties in a seperate file (a stylesheet) for example, which will become clear later. If we wish to change the text size, colour or font being used, all we need to do is alter these properties in the stylesheet once, rather than in every occurance of the tag used in the HTML document(s). Another bonus is that the HTML pages are significantly lighter in kilobytes and so won't eat into your hosting bandwidth limits as much.
This list is by no means definitive but here are a few deprecated tags:
| Deprecated Tags | |
|---|---|
| Tag | Description |
| <center> | Defined centered text |
| <font> | Defined font, color, and size for text |
| <s> | Defined strikethrough text |
| <strike> | Also defined strikethrough text |
| <u> | Defined underlined text |
| <xmp> | Defined preformatted text |
| <isindex> | Defined a searchable index related to a document |
| <dir> | Defined a directory list |
| <menu> | Defined a menu list |
| <basefont> | Defined a default font, color, or size for the text in a page |
| <applet> | Defined an embedded applet |
And inevitably there are also a few deprecated attributes as a result, although some are only deprecated if used with certain tags. One attribute that is deprecated fully is the bgcolor attribute, which was one used for specifying background colours for elements like this:
<body bgcolor="#ff0000">
No doubt as HTML advances even more, other tags and attributes that apply any form of styling within a HTML document will become deprecated, with some worthy candidates surely being the <b> (bold) and <i> (italic) tags. Time will tell.