58 comments

[ 6.5 ms ] story [ 116 ms ] thread
This article is a goldmine—well done. I especially appreciate the care that's been taken to explain the rationale behind each suggestion.

I've worked with Sass fairly extensively, and have picked up some of these practices on my own, but not all of them. I'll definitely be consulting this page in the future.

The author, Hugo Giraudel, also writes one of the absolutest best blogs on Sass (http://hugogiraudel.com/). I've been using Sass heavily since 2009 and consider myself a fairly advanced user, but still learn new and useful things from Hugo's blog on a regular basis. This styleguide looks like an awesome compilation and extension of years of blog articles.
Amazing. This is something that I would happily recommend. I've never seen so mature and deep guidelines and best practices. Kudos to the author.
Disclaimer: This is intended as a helpful correction, not nitpicking.

"... France about to move IN Germany" should be "... from France about to move TO Germany"

Cheers -- and thanks for a useful resource! :)

There are a few similar slip-ups in the article; the author is presumably not a native English speaker. However, despite that - and what really motivated me to comment - I find this really well written, and the odd mistake just adds a bit of character. Very impressed.
True, I am not a native English speaker (French here). Doing my best to fix all those tiny typos. Any report appreciated. :)
Now fixed. My apologies for the awful typo. :)
Great resource. I'm about to use Sass again after a hiatus of ~3yrs. Reading through this has been a great refresher on core principles and best practices.
Very good guidelines, agreeing with 99% of the things and learnt of mix at the same time !
Very good guidelines, agreeing with 99% of the things and learnt of mix at the same time !
Looks really nice but it kind of lacks tackling the difficult issues - like guidelines what to put into classes and how to name them to avoid css class soup. By the way the "7-1" foleer organization is not something you would do in a big programming project (organize things by their type but of use instead). There was a nice blog on it that used analogy of "Socks Drawer".
Looks really nice but it kind of lacks tackling the difficult issues - like guidelines what to put into classes and how to name them to avoid css class soup. By the way the "7-1" foleer organization is not something you would do in a big programming project (organize things by their type but of use instead). There was a nice blog on it that used analogy of "Socks Drawer".
I have to really disagree about @extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be @included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding @extend file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with @extend, yes, but in my opinion dryness and single-point-of-change are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about @extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be @included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding @extend file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with @extend, yes, but in my opinion dryness and single-point-of-change are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about @extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be @included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding @extend file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with @extend, yes, but in my opinion dryness and single-point-of-change are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about @extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be @included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding @extend file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with @extend, yes, but in my opinion dryness and single-point-of-change are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding extend file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with extend, yes, but in my opinion dryness, single-point-of-change, and compile size are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding extend file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with extend, yes, but in my opinion dryness, single-point-of-change, and compile size are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding extend compiled file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with extend, yes, but in my opinion dryness, single-point-of-change, and compile size are far more important than in-file discoverability, assuming your project layout is sane.

I have to really disagree about extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding extend compiled file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with extend, yes, but in my opinion dryness, single-point-of-change, and compile size are far more important than in-file discoverability, assuming your project layout is sane. Extend in sass isn't really any different than using traits in oop languages, it's an incredibly useful pattern when employed correctly.

I have to really disagree about extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding extend compiled file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with extend, yes, but in my opinion dryness, single-point-of-change, and compile size are far more important than in-file discoverability, assuming your project layout is sane. Extend in sass isn't really any different than using traits in oop languages, it's an incredibly useful pattern when employed correctly.

Is the primary benefit of SASS to reduce development time? I find it slows me down having to wait for it to re-parsed on every pageview during active development. Does it offer any other tangible benefits?
Is the primary benefit of SASS to reduce development time? I find it slows me down having to wait for it to re-parsed on every pageview during active development. Does it offer any other tangible benefits?
Is the primary benefit of SASS to reduce development time? I find it slows me down having to wait for it to re-parsed on every pageview during active development. Does it offer any other tangible benefits?
I have to really disagree about extend. Yes, it's easy and potentially disastrous to misuse extend erratically, but used sanely there should never be side effects and your compiled css should be smaller than otherwise.

Regarding side effects, they're easy to avoid if you structure your main file in a logical way. For generic extension, your library of base classes (both actual classes and silent classes) should be included before your components which extend and build on them, therefore any inherited styles come before (and can therefore be overwritten by) the extending component but never the other way around. When extending a component, the extending objects should always be in the same file and come after (e.g. .gallery followed by .gallery-foo and .gallery-bar which both extend .gallery). If full blown objects/components are related enough to extend, they're related enough to be in the same file.

Avoiding extend compiled file size bloat mostly comes from sane nesting behavior that you should be following regardless. Adding single selectors to an extended rule is almost always going to be smaller than inlining/mixing that rule, even for simple rules.

Discoverability is always going to take a hit with extend, yes, but in my opinion dryness, single-point-of-change, and compile size are far more important than in-file discoverability, assuming your project layout is sane. Extend in sass isn't really any different than using traits in oop languages, it's an incredibly useful pattern when employed correctly.

Is the primary benefit of SASS to reduce development time? I find it slows me down having to wait for it to re-parsed on every pageview during active development. Does it offer any other tangible benefits?
Is the primary benefit of SASS to reduce development time? I find it slows me down having to wait for it to re-parsed on every pageview during active development. Does it offer any other tangible benefits?
Try using gulp, gulp-sass (libsass) and gulp-livereload (LiveReload.) It's almost instantaneous and you do not need to reload the page to see your changes. There's also a Grunt equivalent tool chain, but I find gulp faster and prefer to use code for configuration rather than using Grunt's giant config objects.