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
Marwan Solh
2,057 PointsWhy is this not working?
I am having difficulties with the following question:
Create a media query that targets all devices when the viewport width is 1020px or less. Inside the media query, select the .main-header element. Set the background color to tomato and the text color to white.
My answer which is incorrect is:
@media (max-width: 1020px) { .main-header: { background-color: tomato; color: white; } } what is wrong with this?
4 Answers
Jennifer Nordell
Treehouse TeacherHi there! Well, we both thought it looked correct and we were both wrong!
You have an extra colon which is causing an error. Take a look at your selector. You typed:
.main-header: { /* note the extraneous colon here */
background-color: tomato;
color: white;
}
It should be:
.main-header { /* removal of the colon */
background-color: tomato;
color: white;
}
Hope this helps!
Sometimes a second pair of eyes is all you need!
Jennifer Nordell
Treehouse TeacherHi there! Your code looks correct so I'm going to go out on a limb here and make an educated guess. I'm willing to bet that you put that media query at the top of the file. If this is the case, then remember the cascading nature of CSS. Those rules are very likely being overwritten by rules below it.
Try placing your media query at the bottom of the file!
Marwan Solh
2,057 PointsHi Jennifer, thanks for your response.
Putting it at the bottom did not work. This is the first code challenge at the end of the Media Query section of the CSS basics course. So it's the only code in the CSS file. I tired placing it in different places of the field and it still did not work.
Jennifer Nordell
Treehouse TeacherI will take a look at it and get back to you
Marwan Solh
2,057 Pointsahh. Thank you so much!