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

CSS CSS Layout Basics Getting Started with CSS Layout Creating a Layout Wrapper

Why is it not valid to place elements outside when <body> element it is used as the wrapper?

.

1 Answer

You cannot place any elements outside of the body tag which you want to show up on the screen. The body tag is like a wrapper. And everything that you visibly see on the screen goes inside or between the body tags. If you wanted to put a line of text outside of the body, the browser will ignore this and will not treat it properly as HTML, since that statement would be invalid and incorrect.

So just remember, anything you want to show users that visit your website must go between body tags. There are exceptions where you put things outside the body tag such as between the head elements, but they are specifically for SEO purposes and usability but you wont need to know all that at this stage, so i wouldnt worry about that right now.