Whats the consequence of getting your <!DOCTYPE> wrong?

Buongiorno from 10 degrees C wetherby UK :slight_smile:

I understand a HTML page has to start with a !DOCTYPE line but I wonder what are the consequences if your web page was not written in HTML 5 and you strated the first line with <!DOCTYPE html>.

Grazie tanto,
David

no consequence.

It will just change the rules used for validation services like http://validator.w3.org/

Because HTML5 used the principle of “pave the cow-pats”, the idea was that pretty much anything that was valid in HTML4 would continue to be valid in HTML5, to maintain backwards compatibility. There are only a tiny number of things that are likely to become invalid with the move to HTML5, so it is unlikely to be a problem. Even if you do use invalid code (whether outdated or just plain wrong), with HTML (but not XHTML) browsers are generally as forgiving and accommodating of bad code as they can be, so they will do their best to show what they think you meant.

Remember that “HTML5” is just HTML, so as long as your page is HTML, that doctype is fine. The doctype you have cited is intended for HTML (as it indicates itself), that’s all. As said, the validator looks at what doctype you’ve cited to decide what set of rules to validate against, but that’s kind of irrelevant to the actual web page and how it functions in a browser. I now use that doctype in all my pages—because it’s nice and simple—but I don’t use any of those silly elements like <nav> and <section>.

Brill thanks :slight_smile:

HTML 5 is using the short version of the HTML 2 doctype so all that doctype tells anyone is that the HTML is not version 1.