HTML5 defines a number of elements and attributes as obsolete and non-conforming. They are not permitted in markup – they’re not part of the language. However browsers still have to support them, and the the specification determines how.
If you want to write compliant HTML5, you won’t be using them.
If all you want is markup that works, maybe you will.
Three are also four obsolete but conforming attributes, discussed at the bottom of the page.
The W3C document on differences from HTML4 lists three sets of obsolete elements:
- Presentational elements – functionality that should be handled in CSS
- Frame elements, which have been strongly discouraged for some time and damage usability and accessibility
- Miscellaneous elements that “have not been used often, created confusion, or their function can be handled by other elements”
It you’ve been coding XHTML, it’s not likely that you’ve been using these anyway.
- acronym – created confusion, use abbr for abbreviations
- applet – use object instead
- isindex – use forms instead
- dir – use ul instead
The W3C specification lists several more, under 11 Obsolete features:
- bgsound – use audio instead
- listing – use pre and code instead
- noembed – to provide fallack, use object instead
- plaintext – use “text/plain” MIME type instead
- rb – unnecessary inside the ruby element
- xmp – use pre and code instead, and escape < and & with < and &
The same section of the spec lists a large number of attributes that are now obsolete on various elements, with advice on alternative approaches. It is not clear whether some of these remain valid on other elements.
|Attribute||Obsolete on elements…||Alternatives|
|charset||a, link||HTTP Content-Type header on the linked resource|
|coords||a||Use area instead of a for image maps|
|methods||a, link||HTTP OPTIONS feature|
|name||embed, img, option||id attribute|
|rev||a, link||rel attribute with an opposite term
eg rel=”author” instead of rev=”made”
|urn||a, link||href attribute|
|accept||form||accept attribute directly on the input|
|nohref||area||omit href – nohref is unnecessary|
|profile||head||When used to declare which meta terms are used in the document, unnecessary. Omit it and register the names.
When used to trigger specific user agent behaviours: use a link element instead.
|usemap||input||img instead of input for image maps|
|longdesc||iframe, img||Use an a element to link to the description.
For images, use an image map to provide a link from the image to the image’s description.
|lowsrc||img||Use a progressive JPEG image in the src attribute, instead of two separate images.|
|scheme||meta||Use only one scheme per field, or make the scheme declaration part of the value.|
|archive||object||Use the data and type attributes to invoke plugins. To set parameters with these names in particular, the param element can be used.|
|declare||object||Repeat the object element completely each time the resource is to be reused.|
|standby||object||Optimise the linked resource so that it loads quickly or, at least, incrementally.|
|type||param||Use the name and value attributes without declaring value types.|
|event||script||Use DOM Events mechanisms to register event listeners.|
|summary||table||The spec provides several techniques for describing tables.
The best is to “adjust the table such that no explanation is needed”.
|abbr||td, th||Use text that begins in an unambiguous and terse manner, and include any more elaborate text after that. The title attribute can also be useful in including more detailed text, so that the cell’s contents can be made terse.|
|axis||td, th||scope attribute on the relevant th|
|datasrc||a, applet, button, div, frame, iframe, img, input, label, legend, marquee, object, option, select, span, table, textarea||Use script and a mechanism such as XMLHttpRequest to populate the page dynamically.|
|datafld||a, applet, button, div, fieldset, frame, iframe, img, input, label, legend, marquee, object, param, select, span, textarea|
|dataformatas||button, div, input, label, legend, marquee, object, option, select, span, table|
|alink||body||Use CSS instead.|
|bgcolor||body, table, td, th, tr|
|align||caption, col, div, embed, h1 to h6, hr, iframe, img, input, legend, object, p, table, tbody, td, tfoot, th, thead and tr|
|char||col, tbody, td, tfoot, th, thead, tr|
|width||col, hr, pre, table, td, th|
|compact||dl, menu, ol, ul|
|hspace||embed, iframe, img, input, object|
|background||body, table, thead, tbody, tfoot, tr, td, th|
Obsolete but conforming attributes
The spec also describes five obsolete but conforming features – obsolete attributes that you are permitted to use. The attributes on input elements are useful in migrating to HTML5 forms. The others are so constrained that they are pointless – entirely intentionally.
A form input element with type=number may have maxlength and size attributes. This can help legacy browsers that do not support input type=”number”.An img element may have a border attribute. The value must be the string “0”.
An a element may have a name attribute. If the a has an id, the name must be the same as the id. If there is no id, the name must treated like an id – it must be non-blank, and different from all other names on a elements and all ids in the document.