0
0
SASSmarkup~20 mins

Avoiding over-nesting in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nesting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
What is the output CSS selector?
Given this Sass code, what is the compiled CSS selector for the .button hover state?
SASS
$color: blue;
.button {
  color: $color;
  &:hover {
    color: darken($color, 10%);
  }
}
A.button:hover { color: #00008b; }
B.button .hover { color: #00008b; }
C.button:hover { color: darken(blue, 10%); }
D.button:hover { color: blue; }
Attempts:
2 left
💡 Hint
Remember that &:hover appends :hover to the parent selector.
layout
intermediate
2:00remaining
How many CSS rules are generated?
Consider this Sass code avoiding over-nesting. How many CSS rules will be generated?
SASS
.nav {
  display: flex;
  .item {
    padding: 1rem;
  }
  &.active {
    background: green;
  }
}
A2
B4
C3
D1
Attempts:
2 left
💡 Hint
Count each unique selector generated after nesting.
🧠 Conceptual
advanced
2:00remaining
Why avoid deep nesting in Sass?
What is the main reason to avoid deep nesting in Sass stylesheets?
ADeep nesting improves browser rendering speed.
BDeep nesting reduces the file size of the compiled CSS.
CDeep nesting automatically fixes accessibility issues.
DDeep nesting makes CSS selectors too specific and hard to override.
Attempts:
2 left
💡 Hint
Think about how CSS specificity affects styling and maintenance.
📝 Syntax
advanced
2:00remaining
Which Sass code avoids over-nesting?
Choose the Sass code snippet that avoids over-nesting while styling a card component with a title and description.
A
.card {
  .title {
    font-weight: bold;
    .description {
      color: gray;
    }
  }
}
B
.card {
  .title {
    font-weight: bold;
  }
  .description {
    color: gray;
  }
}
C
.card {
  & .title {
    font-weight: bold;
    & .description {
      color: gray;
    }
  }
}
D
.card {
  .title {
    font-weight: bold;
  }
}
.card .description {
  color: gray;
}
Attempts:
2 left
💡 Hint
Avoid nesting selectors inside each other more than one level deep.
accessibility
expert
3:00remaining
How does over-nesting affect accessibility?
Which statement best explains how over-nesting in Sass can indirectly impact web accessibility?
AOver-nesting can cause overly specific selectors that make it hard to update focus styles, reducing keyboard navigation clarity.
BOver-nesting automatically disables screen readers on nested elements.
COver-nesting improves color contrast by grouping styles tightly.
DOver-nesting adds ARIA labels to nested elements by default.
Attempts:
2 left
💡 Hint
Think about how CSS specificity affects style overrides for accessibility features.