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 I should add backgroud-color style to html element when the body element is centered?

the teacher said:"but if you want give your page a full color...you need to add it to your html element."

why i should add it to html?I add it to body,there is seemly no difference from adding it to html element.

Thank you a lot for your help.I get it.

1 Answer

Camilla Holst
Camilla Holst
8,876 Points

If you give your body a width of, for instance, 80 %, then you would be able to use is a the main wrapper and give that another background color than the whole page :) But you are right, there are many ways of achieving the same thing in CSS