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

I need some specific advice for CSS (Cascading Style Sheets)

My instructor recommends that I incorporate CSS comments into my code, along with reorganizing them so that the cascading nature of CSS won't ruin my code.

The problem is that, first of all, rearranging my code into categories really seems like a pain in my ass, especially considering the fact that I would have to take into consideration the position of the code, what comes after or before it, etc.

I would rather just have simple CSS comments that just tell what this line of code is for, and what the next line of code is for. I would like some advice, if you would be so kind.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I would tend to agree with your instructor. This is even taught here at Treehouse. And some sections would likely be somewhat easy to do. Because media queries always come at the bottom of the file, it wouldn't be too hard to do something like this

/*
---- Media Queries ----
*/

It makes your code not only more readable for your instructor, but more importantly, yourself. After stepping away from a site for a month or two you might not remember exactly why you made this particular top margin 10px for example. But if you divide up your CSS into sections like this, it will be easier to find. And the larger/more intricate the site, the more helpful this is.

I might also suggest you take a look at this article which is specifically about using comments. It's very short, but the comments at the bottom show how other people do their comments and that's rather interesting.

Hope this helps! :sparkles:

Thank you for your advice. I am now using CSS comments in my CSS code in order to tidy my code up a bit.