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

HTML HTML Basics Structuring Your Content Grouping Content with <main> and <div>

if DIV tag is to wrap the entire page, why not place it above the <body> tag?

Why did Guil put the <div> tag after the opening <body> tag, if the purpose is to wrap the entire page? Why not include the body as well by putting the div tag before the opening <body> tag?

1 Answer

Steven Parker
Steven Parker
231,261 Points

If you were to put something before the <body>, it would be directly inside the <html> element. But the <html> element is only allowed to contain one <head> and one <body> (and nothing else). And the <head> is only allowed to have metadata content (like <tltle>). So all page content must go inside the <body> tag.

See the MDN pages for html, head and body for more information.

Got it. Thank you.