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

Gabriel Kierkegaard
Gabriel Kierkegaard
4,209 Points

@media all queries not working

Hi, I'm having trouble getting this to work. I even pasted in the teachers project files into my own workspace, just to make sure I hadn't missed anything.

/*Media Queries ---------------------*/

@media all (max-width: 960px) {
  body {
    background: royalblue;
  }
  p {
    color: white;
  }
}
Gabriel Kierkegaard
Gabriel Kierkegaard
4,209 Points

I can get the seagreen part to work as the only thing. But the royalblue and darkred won't display.

/*Media Queries ---------------------*/

@media all (max-width: 960px) {
  body {
    background: royalblue;
  }
}

@media (max-width: 480px) {
  body {
    background: darkred;
  }
}

@media (min-width: 481px) and (max-width: 700px) {
  body {
    background: seagreen;
  }
  p {
    color: white;
  }
}

1 Answer

Try adding the word 'and' after all as below

@media all and (max-width: 960px) { 
  body { background: royalblue; } 
  p { color: white; } 
}
Gabriel Kierkegaard
Gabriel Kierkegaard
4,209 Points

Hi thanks for the help, it worked. I just don't understand why I had to put and in since the teacher didn't?