I've used the video
element in my web page but the DOCTYPE is HTML4.
Then, I can use frameset
in HTML5 also.
Why there is no restriction on tag usage?
I've used the video
element in my web page but the DOCTYPE is HTML4.
Then, I can use frameset
in HTML5 also.
Why there is no restriction on tag usage?
HTML is designed to be tolerant of errors. Using a particular doctype won’t make browsers reject tags that weren’t around when that doctype was published.
This is why the current HTML doctype is just
<!DOCTYPE html>
, i.e. unversioned. It more accurately reflects HTML as an ever-evolving standard.Why should browsers ensure that? If all browsers would only display valid HTML, great! But then one browser comes and says: "Oh, my users can’t view all this invalid sites, but some of them would be really useful … let me show them those sites anyway!" Now this browser works with more sites than any other browser. You can bet what the other browsers will do.
Also, user agents that support HTML5 can’t really tell if a page is in HTML 4.01 or HTML5, as the HTML 4.01 DOCTYPE is a "obsolete permitted DOCTYPE string" in HTML5. Which means: Even if you use the HTML 4.01 DOCTYPE, those browsers will probably interpret your page according to HTML5.
Why HTML4 elements that are "obsolete" in HTML5 work in HTML5 documents? Because HTML5 user agents must support them (but authors must not use them!): see Frames in the HTML5 spec, which defines what user agents shall do with
frameset
.The
doctype
declaration is, of old, merely a hint to the browser on how to parse the content of the page. As of HTML5, this was dropped and replaced with a simple generic<!doctype html>
that is identical for all current and future versions of the standards since HTML is now sufficiently backwards compatible to allow progressive development.Long story short, all a modern browser does with the doctype nowadays is decide whether to parse in 'tag soup' or 'quirks' mode, or 'standards compliant mode'. The supported elements it then finds with that parser have nothing to do with the doctype.