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

What is the best way to organize your CSS code with comments?

CSS pros what do you guys think of this? If you guys don't think it's a good way to organize CSS code please let me know what the best way to organize CSS code is.

/******* HEADER STYLES *********/

/********* MAIN SECTION STYLES ***********/

/********** FOOTER ***************/

/*********** MEDIA QUERIES **********/

1 Answer

This is fine if you are only writing styles for a single webpage or two. If you're still kinda new to CSS and web development, just do this and see how it goes, don't worry too much how the "pros" do it. But once you begin styling an entire website, those separators -- or even bigger comment block dividers -- are going to move so many hundreds of lines away from each other that they won't be very useful and you might be a lot happier making each of those groups into separate files. Going further down the rabbit hole, this is actually one major benefit of using a pre-processor like Sass, which can combine a whole bunch of Sass "partial" files into one big CSS file on the fly, so that you can write your styles in a bunch of separate, clearly contained files that keep things really organized. Then you won't need these dividers at all. :)