As many of you may be aware, validating your pages in HTML5 has become a whole new adventure.
Along with changes in what now constitutes “valid” and “invalid” markup, the HTML5 Validator (which, by the way, is the same tool that runs the W3C’s HTML5 validator) will provide some warnings about obsolete features in HTML5.
Feel free to go through that document on the W3C’s site, but here I’ll touch on some things that you may want to be aware of with regards to obsolete elements and attributes.
There’s No More “Deprecated”
Many developers will be familiar with the word “deprecated” when referring to elements and attributes that no longer validate or that are no longer part of the current HTML spec. This was the term used in previous versions of HTML, but not with HTML5.
So, for example, if you validate a document using an XHTML Strict doctype, and you use the
<iframe> element or the
target attribute, the validator will output the two errors shown in the screen grab below:
This has changed to a large degree in HTML5. In the case of
target, those features are now valid in HTML5, so there’s no problem–the page will validate and there won’t be any warnings.
Obsolete But Conforming Features
Let’s try instead to validate an HTML5 document that contains obsolete features that are still considered valid in HTML5. Here’s a screen grab of the message you’ll see if you validate a document that uses an
<img> element with the
border attribute, in addition to an
<a> element with the
name attribute (both attributes of which are now obsolete in HTML5 in those contexts):
So, according to the HTML5 validator, the page is still valid, but you are warned to instead use alternative methods to accomplish the same thing.
For a full list of “obsolete but conforming” features see the appropriate section in the same W3C document.
Totally Obsolete Elements
On the other hand, some elements are just downright wrong and should not be used. So you won’t just get a warning, you’ll get a full-blown error with a recommendation to accomplish the same thing in a valid manner.
Some of the error-inducing obsolete elements include
<blink>. You can see a full list of non-conforming obsolete features here.
Will Obsolete Features Break Your Pages?
Generally speaking, no, these invalid elements will not break your pages. The HTML5 doctype is not a doctype to identify a markup language, it’s a doctype to identify a web document, whether it’s using old elements or new stuff like
I know I’ve probably oversimplified the definition of a doctype here, but generally speaking, that’s what is happening. That’s why it’s okay to change old documents to an HTML5 doctype without fear of your pages breaking or rendering differently.
Also, browser makers are required to support those old obsolete elements. That same document contains a section called Requirements for Implementations, which basically tells browser makers how obsolete elements should be handled when the page is rendered.
Of course, when we say that browser makers are “required” to do this, it’s not as if they’ll be arrested or fined if they don’t; it’s really just a recommendation, but I think for the most part browser makers have complied.
I guess if anything, this should help further drive home the point that it’s okay to to start changing pages with old doctypes to the HTML5 doctype. It’s true that the pages may not technically validate anymore (in most cases they will), but they will still render the same.