Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Implementing 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
Andrew McCormick
17,729 Points

the 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.