The very first line of an HTML document has to be a way for you to let the browser know what kind of document it is going to read.
You see, over the course of Internet history, there have been numerous versions of HTML. So when creating a website, you will need to declare to the browser exactly which version of HTML you are intending to use.
(You're going to use the latest version; HTML5, yes, you can be a rebel and use one of the earlier versions, but you're just cutting yourself off from many great advances that have been made since the early days of HTML and XML.)
How exactly do you declare to browsers which version of HTML you are using? By using the DOCTYPE declaration. I say declaration, because the DOCTYPE isn't a tag, but a declaration.
The DOCTYPE is a vital component to all websites, which is kind of exactly why it is the first line of every HTML document.
How We Do...
Adding a DOCTYPE declaration is as simple as opening up an HTML file, and typing the same line of code every time. Until a new version of HTML comes out, to which you need to use that new declaration, you will continue to use this line of code for every HTML document.
Now notice a couple of things; the first being the exclamation mark before DOCTYPE, that's important, don't forget it, trust me, you will save yourself a minor headache. Next, while the DOCTYPE declaration isn't case-sensitive, it's just good form to have DOCTYPE capitalized and html lowercase. Lastly, because it is a declaration, you won't need a closing tag.
That's pretty much it. By adding the DOCTYPE declaration, you have now informed the web browser which version of HTML you are going to use, and you are now ready for the next part of the document.
Encycodepedia is a reference guide to the common syntax and terminology used in everyday programming.
Encycodepedia HTML covers the structural component of building websites.