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 trialMasae Okada
5,742 Pointsthe difference between <!DOCTYPE html> and <html></html>
if the <!DOCTYPE html> tells the browser "This is HTML document", why do I have to write <html></html> tag?
What is the purpose to write <html> tag after writing <!DOCTYPE>?
Thanks for helping me ahead ;)
3 Answers
Pavle Lucic
10,801 Points<!DOCTYPE html> - It is a DECLARATION . It tells browsers what version of HTML are you using, which helps them to properly render the elements on webpage.
HTML tag have three functions:
- it tells the browser that this is an HTML document
- represents the root of an HTML document
- it is the container for all other HTML elements (except for the <!DOCTYPE> tag).
James Casavant
21,522 PointsThe !DOCTYPE html tag defines the TYPE of document as HTML.
After the browser understands the TYPE of document is HTML, we may now define the HTML document itself by the code we create between the html/html tags.
Or, to say it in a different way:
!DOCTYPE html
-a web-document consisting of HTML pages.
HTML headbodyfooter /HTML
-an HTML page consisting of a header, body, and footer.
Johnatan Guzman
Courses Plus Student 2,360 PointsWith !doctype the browser knows that the document is html5 which is much easier than to declare a previous version of html which was something about !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">. So !doctype declares the version of the html (or which version the browser can expect).