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

Why would you add a mixin for element and modifier which only increases verbosity and abstraction / complexity?

This is regarding the BEM Mixins video (https://teamtreehouse.com/library/modular-css-with-sass/sass-and-bem/bem-mixins)

&__ v.s. @include e() {}

&__ is less verbose, less nesting, and less abstract.

2 Answers

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi Dave Rapi,

Both methods produce the same output, and it's up to you to choose what works best for your project. Personally, I like storing that information in mixins, as mixins are great for replacing common patterns.

&__ and &-- are a patterns being repeated hundreds (maybe thousands) of times in our code. If—for some reason—something in the pattern needs to change, it's done in one place vs. hundreds...

Understood, thanks! Wasn't sure if I was missing something or if it was just a personal preference thing. I think I'll stick with &__ and &-- and wrap them if / when the scenario comes up where I need to.

Excellent vids so far. Very glad someone covered BEM and SMACSS. Any plans to add one on OOCSS?