Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS How to Make a Website CSS: Cascading Style Sheets What is CSS?

What do you use as an element selector if you want the whole background to be one specific color?

I understand what you do if you want the footer or nav to be a certain color.

Footer{background-color: green; }
nav { background-color: orange;}

but what if I want to make the whole background-color one color what would be the element selector? Is this when using Div's comes in?

3 Answers

Kelly von Borstel
Kelly von Borstel
28,880 Points

I believe you use body element as selector if you want the entire background of page affected.

body {
    background-color: green;
}
Seth McCombs
Seth McCombs
16,767 Points

You can set the background to the body element

body { 
     background-color: red; 
}

or you can create divs, using a wrapper div is a very common (a div with the class "wrapper") to contain all other elements.

thanks!