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

HTML How to Make a Website Responsive Web Design and Testing Write CSS Media Queries

Why does the h1 font size work, and the h2 does not?

I succeeded with the min width to 480px and then the min width 660px is written the same way for the h2 font change, but it won't let me past it.

2 Answers

Hi Joyce, what error you are getting? Can you post your solution? The two media directives is indeed similar, take a look in my example, see if you are missing something:

/* Create a breakpoint for devices 480 pixels wide or larger. 
Inside the breakpoint, set the h1 font-size to 2.5em. */

@media only screen and (min-width: 480px) {
  h1 {
    font-size: 2.5em;
  }
}

/* After the first breakpoint, create a second breakpoint for devices 660 pixels wide or larger.
Inside the breakpoint, set the h2 font-size to 1.75em. */

@media only screen and (min-width: 660px) {
  h2 {
    font-size: 1.75em;
  }
}

Thank you, I honestly don't know what the difference was except in the lesson there was no "only" in the code. I want to thank you for your quick response!!!

Sorry Joyce for the confusion with the only keyword. You can omit this keyword for the challenge if you want.

Here is a quote straight from W3C to explain this one.

"The keyword ‘only’ can also be used to hide style sheets from older user agents. User agents must process media queries starting with ‘only’ as if the ‘only’ keyword was not present."

Not sure if that stills useful, but I kind of stick with it.

Thanks, it worked without it for the first one, but only worked with it for the second one. Go figure! :)