This is the information provided for the second step in the Learn HTML course:
<!DOCTYPE html> must be the first line of code in all of your HTML documents. If you don’t use the declaration, your HTML code will likely still work, however, it’s risky. For now, the browser will correctly assume that the html in <!DOCTYPE html> is referring to HTML5, as it is the current standard.
In the future, however, a new standard will override HTML5. Future browsers may assume you’re using a different, newer standard, in which case your document will be interpreted incorrectly. To make sure your document is forever interpreted correctly, always include <!DOCTYPE html> at the very beginning of your HTML documents.
In the first paragraph, it sounds like using <!DOCTYPE html> just tells the browser to interpret the document using the current standard. In the second paragraph, it sounds like using the <!DOCTYPE html> declaration ensures that your document “is forever interpreted correctly.” Which is correct?
Or is the <!DOCTYPE html> declaration unique to HTML5 and other versions of HTML have different declarations?
here is the doctype for html4 (the version before html5, go figure ):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
html5 is the current standard, but we want to ensure that all browsers get it right, so we include it in a declaration. We rather explicitly state something during programming, then relying on other programs (webbrowsers) to guess it right
So, just to make sure I’m understanding this correctly, <!DOCTYPE html> informs the browser that the version of html that I’ve used is HTML5, and would interpret everything as such.
If I used the declaration that you sited: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
which was the doctype for html4, the browser would interpret my document as having been written in html4.
So when html6 is introduced, there will be a new doctype declaration created for it? <!DOCTYPE html> is just specific to HTML5?
Thanks so much for your help, and for being patient with me while I fumble through this!
I think what was confusing to me is that there aren’t any version numbers used in the doctype declarations. I guess it doesn’t matter to the browsers interpreting the information but it’s confusing to my human brain. And never mind, the doctype declaration for html4 does include the version number. I see it now.