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 How to Make a Website Responsive Web Design and Testing Build a Three Column Layout

Gabriel Rowe
Gabriel Rowe
5,204 Points

Why do we have to indent comment @1:38? It seems it would be nested within the query without indentation.

Any thoughts?

2 Answers

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

As long as there are the proper number of opening and closing brackets/braces, the code doesn't care how the CSS is laid out. It sees both of the following as the same:

@media screen and (max-width: 768px) {
  li {
    border: 1px solid black;
  }
}
@media screen and (max-width: 768px) {li{border: 1px solid black;}}

The reason we indent things is to make it easier for our human eyes to be able to more easily keep track of and maintain code.

In the case of comments, they actually can be put anywhere, but it's better to put your comment with the piece of code it is explaining. So, if you are explaining what the following if/then statement is doing, it is best to have the comment indented to the same level so you and others know what the comment is about.

Gabriel Rowe
Gabriel Rowe
5,204 Points

Thanks! That was really helpful.