SASS Patterns and best practices?

I am aggressively catching up as a front-end developer. I preface my question with that statement because I feel embarrassed that I’m only now using SASS in 2015. Ugh.

So I just worked on my first project with SASS. It’s fantastic. A huge relief. While I near it’s development, I realize I made a big mess in my SASS code partly due to reasons of learning as I go, experimenting with different techniques, and rushing through some details.

My question: Are there SASS patterns and best practices? I did introduce myself to Compass in this process as well.

For example are there pros and cons to this approach of having elements and classes all within specific sections:

#section_a {
    header {
        hgroup {
            h1 {
                //stuff
            }
        }
    }
    
    .box {
        //stuff
    }
}

I’m not using it and I don’t plan on ever :wink: .

Perhaps this will help you - http://www.sitepoint.com/8-tips-help-get-best-sass/

1 Like

Depends on how well you(or others) can comprehend your code.

Having too many nested rules could affect the readability of your code. I usually break apart my rules if they start getting too long e.g

#section_a {
    header {
        hgroup {
            h1 {
                //stuff
            }
        }
    }
}

// then
#section_a {
   .box {
     // more rules here
   }
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.