Challenge - 5 Problems
BEM SASS Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the output CSS of this SASS code using BEM nesting?
Given the following SASS code, what CSS will it produce?
.block {
&__element {
color: red;
}
}SASS
.block { &__element { color: red; } }
Attempts:
2 left
💡 Hint
Remember that & replaces the parent selector exactly in SASS nesting.
✗ Incorrect
The & symbol in SASS replaces the parent selector. So &__element becomes .block__element in CSS.
❓ selector
intermediate2:00remaining
Which selector matches the BEM modifier in this SASS snippet?
Look at this SASS code:
Which CSS selector does it generate?
.block {
&--active {
background: green;
}
}Which CSS selector does it generate?
SASS
.block { &--active { background: green; } }
Attempts:
2 left
💡 Hint
Modifiers in BEM use double dashes and are appended directly to the block name.
✗ Incorrect
The & replaces the parent selector exactly, so &--active becomes .block--active in CSS.
❓ layout
advanced2:30remaining
How does this nested BEM SASS code affect layout?
Consider this SASS code:
What will be the layout behavior of .card__header and .card__body inside .card?
.card {
display: flex;
&__header {
flex: 1;
}
&__body {
flex: 2;
}
}What will be the layout behavior of .card__header and .card__body inside .card?
SASS
.card { display: flex; &__header { flex: 1; } &__body { flex: 2; } }
Attempts:
2 left
💡 Hint
Flex container distributes space according to flex values of children.
✗ Incorrect
With display:flex on .card, children with flex:1 and flex:2 share horizontal space in ratio 1:2.
❓ accessibility
advanced2:30remaining
Which BEM SASS nesting approach improves accessibility for a button with icon?
You want to style a button with an icon inside using BEM and SASS nesting. Which code snippet best supports accessibility by semantic HTML and clear structure?
.button {
&__icon {
margin-right: 0.5rem;
}
}SASS
.button { &__icon { margin-right: 0.5rem; } }
Attempts:
2 left
💡 Hint
Semantic elements and hiding decorative icons from screen readers help accessibility.
✗ Incorrect
Using
🧠 Conceptual
expert3:00remaining
What is the main advantage of using BEM naming with SASS nesting in large projects?
Why do developers prefer combining BEM naming conventions with SASS nesting for CSS in big projects?
Attempts:
2 left
💡 Hint
Think about how naming and nesting help developers understand and manage styles.
✗ Incorrect
BEM naming gives predictable class names, and SASS nesting groups related styles, making CSS easier to maintain and reuse in large projects.