Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Kaisar Andreti Mustiadi
5,364 Pointsabout <!DOCTYPE html>
What happen if i don't type <!DOCTYPE html> ? i notice my webpage still displayed properly in web browsers though.
5 Answers
Nam Pham Duong Nhat
Courses Plus Student 1,184 PointsIf your page doesn't has that tag, the browser won't understand some new HTML5 tag
James Barnett
39,199 PointsDoctype is required to conform to the HTML5 spec. However, a browser will try to render just about anything you give it since there's no such thing as an HTML error message. You will however notice weird things sometimes happen when you try to write CSS (or JavaScript) against pages that don't validate.
The term for this by the way is tag soup.
Arthur Verschaeve
20,816 PointsHowever the browser will do everything you want, always include the doctype on every page. When you don't include this, you're writing syntactically incorrect html.
In the HTML5 standard:
DOCTYPEs are required for legacy reasons. When omitted, browsers tend to use a different rendering mode that is incompatible with some specifications. Including the DOCTYPE in a document ensures that the browser makes a best-effort attempt at following the relevant specifications.
However, I you want to make you're web pages shorter, you may actually exclude <head> and <body>. I recommend you to watch Paul Irish' presentation on this. I believe the part about DOM parsing starts at 16 minutes
Diana Lescure
11,455 PointsWhen you use a DOCTYPE declaration you are letting the browser know that the content following that tag is written in a certain version of HTML (in this case HTML5). Most of the times this won't affect your website, but every once in a while you'll have certain content (tags) that might not work at all since the browser won't know what version of HTML it should use to interpret your content, since HTML5 introduced so many new tags and keeps introducing them over the time.
Kaisar Andreti Mustiadi
5,364 PointsGreat! Thank you all