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 Unused CSS Stages Media Queries Media Features and Media Types

Incorrect background-color?

I am on challenge task 2 of 3 and am being asked to add a media query that changes the background color of the body element to #4682b4 when the screen size is 480px or less.

This is the code I have written:

@media screen and (max-width: 480px) {
     body {
          background-color: #4682b4;
         }

I keep getting an error asking if I have specified the correct background color?

I've tried redoing it several times and I know i must be doing something wrong but I cannot figure it out.

Any hints?

4 Answers

Hi Emma,

Did you close off your previous 768px media query? That would cause this one not to work.

As Dustin mentioned, you should close this one off too. It will still work if it's the last thing in your css but if you add something after it then it won't work. It's good practice to always close them off.

Hey Emma! Looks like you just need to close off the end of your media query with a curly bracket }.

@media screen and (max-width: 480px) {
     body {
          background-color: #4682b4;
         }
} /* Missing bracket */

Thanks Dustin,

I've tried that and it still doesn't work. I feel like i'm going mad lol

Pretty common mistake :smiley: glad you got it.

Aha Jason, thank you that's cracked it!

Its always the simple things isn't it.

You're welcome.