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

Jessica Raines
Jessica Raines
3,785 Points

Keep getting error

I can't figure out what I am doing wrong. The challenge is: Create a media query that sets the body element's background color to #FF6347 and its text color to white if the viewport width is 768px or less. This is what I have, which passed initially, but then after I did the 2nd challenge it said the first no longer passed. @media screen and (max-width: 768px) { body { background: #FF6347; color: white; } } @media screen and (min-width: 480px) { body { background: #4682B4; } } The second part was what I did for the 2nd challenge.

2 Answers

Stone Preston
Stone Preston
42,016 Points

you need to use max-width in your second query as well, not min-width. when you used min width it basically overrides your first media query, which is why task 1 was no longer passing

/* Complete the challenge by writing CSS below */
@media screen and (max-width: 768px) {
        body {
      background: #FF6347;
        color: white;
    }
}

/* use max-width: 480px here */
@media screen and (max-width: 480px) {
  body { 
    background: #4682B4;
  }
}
Jessica Raines
Jessica Raines
3,785 Points

That was it. Thank you so much.