0
0
SASSmarkup~20 mins

Combining & with pseudo-classes in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Pseudo-Class Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
What CSS selector does this Sass code produce?
Given the Sass code below, what is the equivalent CSS selector for the nested rule?
SASS
&:hover { color: red; }
A.button & :hover
B.button :hover
C&:hover
D.button:hover
Attempts:
2 left
💡 Hint
Remember that & represents the parent selector in Sass.
selector
intermediate
2:00remaining
What is the output selector for this Sass snippet?
Consider this Sass code inside a .nav class: &:not(:last-child) { margin-right: 1rem; } What CSS selector does it generate?
SASS
&:not(:last-child) { margin-right: 1rem; }
A.nav :not(:last-child)
B.nav:not(:last-child)
C&:not(:last-child)
D.nav:not(:last-child) {}
Attempts:
2 left
💡 Hint
The & replaces the parent selector exactly.
rendering
advanced
2:00remaining
Which option correctly styles only active links inside .menu?
You want to style only active links inside a .menu container using Sass and &:active. Which option produces the correct CSS?
SASS
.menu {
  a {
    &:active {
      color: blue;
    }
  }
}
A.menu a:active { color: blue; }
B.menu :active a { color: blue; }
C.menu a &:active { color: blue; }
D&.menu a:active { color: blue; }
Attempts:
2 left
💡 Hint
The & represents the current selector, which is 'a' inside .menu.
accessibility
advanced
2:00remaining
Which Sass selector combination improves keyboard accessibility for buttons?
You want to style buttons when they are focused or hovered to improve keyboard accessibility. Which Sass code snippet correctly combines & with pseudo-classes?
SASS
button {
  &:hover, &:focus-visible {
    outline: 2px solid blue;
  }
}
Abutton:hover, button:focus-visible { outline: 2px solid blue; }
Bbutton &:hover, button &:focus-visible { outline: 2px solid blue; }
C&:hover, &:focus-visible button { outline: 2px solid blue; }
Dbutton:hover &focus-visible { outline: 2px solid blue; }
Attempts:
2 left
💡 Hint
The & replaces the parent selector exactly without adding spaces.
🧠 Conceptual
expert
3:00remaining
What is the output CSS selector for this Sass code?
Given this Sass code: .nav { & > ul { & > li:first-child { color: green; } } } What is the full CSS selector generated for the color property?
SASS
.nav {
  & > ul {
    & > li:first-child {
      color: green;
    }
  }
}
A.nav & > ul > li:first-child { color: green; }
B.nav > ul li:first-child { color: green; }
C.nav > ul > li:first-child { color: green; }
D.nav ul > li:first-child { color: green; }
Attempts:
2 left
💡 Hint
Each & replaces the full parent selector at its nesting level.