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 trialChristian Elssner
Courses Plus Student 809 PointsImplementing Media Queries section (importance of comma)
@media screen and (max-width: 480px) {
.grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6, .grid_7, .grid_8, .grid_9, .grid_10, .grid_11, .grid_12 { width: 100%; }
In this section I noticed that leaving off the comma in .grid_12 gets everything properly in one column for the 480px width.
If i add a comma to .grid_12, and nothing is changed. What feature of CSS makes leaving the comma out so necessary for this code to work properly?
2 Answers
Andrew McCormick
17,730 Pointsthe comma tells CSS that another selector is coming. Kind ok like saying ".grid_1 AND .grid_2, AND .grid_3, etc" . When you put a comma after .grid_12 you are telling it to select another element, but you don't tell it what element to select so the statement is invalid and is ignored.
James Barnett
39,199 PointsHere's a tutorial where you can review CSS selectors and how grouping works.