Question about <!DOCTYPE html> - Learn HTML- Step 2

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?

Thanks for the help!

here is the doctype for html4 (the version before html5, go figure :stuck_out_tongue: ):


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

How can I display code in my posts without it formatting itself into my post? I’m having trouble finding that in the FAQs. Thank you!

Edit: I think I needed to use backticks.

i would check the new user section, it contains this topic:

which also explains formatting, and a link to a more detailed topic

And it should be in FAQ as well, the FAQ on the forum that is:

FAQ - Codecademy Forums

simple do: ctrl + f → format

ensure you scrolled down, so all FAQ are loaded

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:
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!



you would have to ask w3c, the organisation which makes the web standard recommendations. Its impossible to say with certainty what they (w3c) will do.

also can’t be said with certainty, the future is uncertain. But very likely, yes.

windows 10 is the latest windows version, it will only get updates but no new releases, so no new number. Maybe the same will happen to html, we don’t know

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.

Thank you again! :slight_smile:

Be glad that the doctype deceleration for html5 is so easy, it could be remembered if desired, good luck with remembering the one for html4 xD

you shouldn’t bother to remember much, trust your muscle memory (interesting english word) and for the rest you can use documentation

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.