Home | SkillForge Blog | What does the DOCTYPE do in HTML?

What does the DOCTYPE do in HTML?

HTML5, Web Design

What is the DOCTYPE?  When coding in HTML you will see this really weird looking line up there at the top.  It usually looks like this:

<!DOCTYPE html>

Simply enough, this line tells the browser what version of HTML is being used to create the website.  Back in the day, with HTML4, DOCTYPES were really long lines of text that were almost impossible to remember because they looked like this:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

and

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>

and

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>

Depending on if you wanted the language to be handled in a more strict (not allowing mistakes in the code) way or more lenient, you would use either the first or second DOCTYPE.  If you used frames (that’s going WAY back), you would use the frameset DOCTYPE.  Either way, I think the whole web is very happy that in HTML5 they decided to make it a lot smaller and easier to remember.  If you want to learn more about web design/development be sure to check out our HTML/CSS/JavaScript Training.  Have an amazing day!