Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?