0
0
SASSmarkup~20 mins

State class generation (hover, active, disabled) in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
State Class Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the output CSS of this SASS snippet?
Given this SASS code, what CSS does it generate?
.btn {
  background: blue;
  &:hover {
    background: green;
  }
  &.disabled {
    background: gray;
  }
}
SASS
.btn {
  background: blue;
  &:hover {
    background: green;
  }
  &.disabled {
    background: gray;
  }
}
A
.btn { background: blue; }
.btn:hover { background: gray; }
.btn.disabled { background: green; }
B
.btn { background: blue; }
.btn:hover { background: green; }
.btn.disabled { background: gray; }
C
.btn { background: blue; }
.btn.disabled:hover { background: green; }
D
.btn { background: blue; }
.btn:hover.disabled { background: gray; }
Attempts:
2 left
💡 Hint
Look at how the & symbol combines with pseudo-classes and classes.
🧠 Conceptual
intermediate
1:30remaining
Which selector targets the active state in SASS?
You want to style a button when it is being clicked (active state). Which SASS nested selector correctly targets this state?
SASS
.btn {
  // your code here
}
A&:active { background: red; }
B&.active { background: red; }
C&.disabled { background: red; }
D&:hover { background: red; }
Attempts:
2 left
💡 Hint
Active state is a pseudo-class triggered when clicking.
selector
advanced
2:30remaining
What CSS does this SASS produce for combined states?
Consider this SASS code:
.btn {
  color: black;
  &:hover, &:focus {
    color: blue;
  }
  &.disabled {
    color: gray;
    pointer-events: none;
  }
}

What is the correct CSS output?
SASS
.btn {
  color: black;
  &:hover, &:focus {
    color: blue;
  }
  &.disabled {
    color: gray;
    pointer-events: none;
  }
}
A
.btn { color: black; }
.btn:hover:focus { color: blue; }
.btn.disabled { color: gray; pointer-events: none; }
B
.btn { color: black; }
.btn:hover, .disabled:focus { color: blue; }
.btn.disabled { color: gray; pointer-events: none; }
C
.btn { color: black; }
.btn:hover, :focus { color: blue; }
.btn.disabled { color: gray; pointer-events: none; }
D
.btn { color: black; }
.btn:hover, .btn:focus { color: blue; }
.btn.disabled { color: gray; pointer-events: none; }
Attempts:
2 left
💡 Hint
Check how multiple selectors separated by commas are expanded with &.
layout
advanced
1:30remaining
How to disable pointer events for a disabled button in SASS?
You want to make a button unclickable and visually disabled using SASS. Which nested rule correctly disables pointer events and changes opacity?
SASS
.btn {
  background: green;
  color: white;
  &.disabled {
    // your code here
  }
}
A
opacity: 1;
pointer-events: auto;
B
opacity: 0.5;
pointer-events: auto;
C
opacity: 0.5;
pointer-events: none;
D
opacity: 1;
pointer-events: none;
Attempts:
2 left
💡 Hint
Disabled means less visible and no mouse interaction.
accessibility
expert
3:00remaining
Which approach improves accessibility for disabled buttons?
You have a button styled with a .disabled class in SASS. Which additional attribute or practice improves accessibility for keyboard and screen reader users?
SASS
.btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}
AAdd aria-disabled="true" attribute and tabindex="-1" to the button element.
BAdd role="button" attribute only.
CAdd tabindex="0" to make it focusable.
DRemove the button element and replace with a div.
Attempts:
2 left
💡 Hint
Disabled elements should not be focusable and should announce their state.