0
0
SASSmarkup~5 mins

Combining & with BEM naming in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the & symbol represent in Sass when used with BEM naming?
The & symbol represents the parent selector. It helps to write nested styles by referring back to the current block or element name in BEM.
Click to reveal answer
beginner
How do you write a BEM modifier using & in Sass?
You append the modifier to the parent selector using &--modifier. For example, .button { &--primary { color: blue; } } styles .button--primary.
Click to reveal answer
beginner
Why is combining & with BEM naming helpful in Sass?
It keeps your CSS organized and avoids repeating the full class name. It also makes your code easier to read and maintain by showing the relationship between blocks, elements, and modifiers.
Click to reveal answer
beginner
Write a Sass snippet using & to style a BEM element .card__title inside .card.
.card {
  &__title {
    font-weight: bold;
  }
}
This compiles to .card__title { font-weight: bold; }.
Click to reveal answer
beginner
How would you style a BEM modifier .nav__item--active using & inside .nav__item?
.nav__item {
  &--active {
    color: red;
  }
}
This targets .nav__item--active with red text color.
Click to reveal answer
In Sass, what does &__element inside .block represent?
AA sibling element with class <code>.element</code>
BA child element with class <code>.block__element</code>
CA modifier of <code>.block</code>
DAn unrelated class
How do you write a BEM modifier .button--large using & inside .button in Sass?
A<code>.button { &--large { ... } }</code>
B<code>.button { &__large { ... } }</code>
C<code>.button { &-large { ... } }</code>
D<code>.button { &.large { ... } }</code>
What is the main benefit of using & with BEM in Sass?
AIt disables CSS inheritance
BIt changes the HTML structure
CIt adds JavaScript functionality
DIt allows nesting without repeating class names
Which Sass code creates the class .menu__link--active?
A<code>.menu__link { &--active { ... } }</code>
B<code>.menu { &__link--active { ... } }</code>
C<code>.menu { &--link--active { ... } }</code>
D<code>.menu__link--active { ... }</code>
If you want to style .header__nav inside .header using Sass and &, which is correct?
A<code>.header { &--nav { ... } }</code>
B<code>.header__nav { & { ... } }</code>
C<code>.header { &__nav { ... } }</code>
D<code>.header__nav { ... }</code>
Explain how the & symbol helps write BEM-style CSS in Sass.
Think about how nesting works in Sass and how BEM class names are structured.
You got /4 concepts.
    Write a Sass example using & to style a block .card, an element .card__header, and a modifier .card--featured.
    Remember BEM uses double underscores for elements and double dashes for modifiers.
    You got /3 concepts.