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

Bug in the media challenge?

I have tried this challenge 15 times and as far I can tell, my code is correct. What am I missing?

Next, create a new media query that targets all devices when the viewport width is 768px or narrower. Inside the media query, target the .title element and set the font-size to 1.4rem. Finally, target the h1 element and set its font-size to 5rem. Bummer! Did you specify the correct font size for '.title'? Preview Get Help Recheck work style.css index.html

1 /* Complete the challenge by writing CSS below */ 2 @media (max-width: 1020px) { 3 .main-header { 4 background: tomato; 5 color: white; 6 } 7 @media (max-width: 768px) { 8 .title { 9 font-size: 1.4rem; 10 } 11 } 12 h1 { 13 font-size: 5rem; 14 } 15 } 16 ​ 17 ​

1 Answer

Elijah Gartin
Elijah Gartin
13,182 Points

Hey Kathleen,

Looks like there is an issue with your brackets. You might need to play around with what I've done here depending on what it is exactly looking for.

Keep in mind, all the styles you want need to reside in the brackets for whatever break point you choose.

@media(max-width:####){<all styles for this max-width here>}

The brackets before were keeping h1 under the 1020px and not the 768px. I went ahead and modified the bracket structure and pasted it below. The way I've trained my brain is to think of it as modular as possible. Anything that has a bracket enclosure is a module and as long as I keep my modules together (with starting and ending bracket) I'm usually good to go. Try to use indentation to establish your hierarchy. Using a text editor like Atom or Visual Code helps me because I can click on a bracket and it will show me what it considers it's partner bracket so I can debug potential issues like this.

Before:

 /* Complete the challenge by writing CSS below */
@media (max-width: 1020px) {
  .main-header {
    background: tomato;
    color: white;
}
@media (max-width: 768px) {
  .title {
    font-size: 1.4rem;
}
}
h1 {
  font-size: 5rem;
}
}

After:

​ /* Complete the challenge by writing CSS below */
@media (max-width: 1020px) {
  .main-header {
    background: tomato;
    color: white;
  }
}
@media (max-width: 768px) {
  .title {
    font-size: 1.4rem;
  }
  h1 {
    font-size: 5rem;
  }
}

Hopefully this fixes your issue. Good luck!