0
0
SASSmarkup~20 mins

Future CSS features replacing SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Future CSS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding CSS Nesting vs SASS Nesting
Which of the following CSS snippets correctly uses the new CSS nesting feature to replicate the SASS nesting below?

.menu {
  color: black;
  .item {
    color: red;
  }
}
A
.menu {
  color: black;
  & .item {
    color: red;
  }
}
B
.menu {
  color: black;
  .item {
    color: red;
  }
}
C
.menu {
  color: black;
  & > .item {
    color: red;
  }
}
D
.menu {
  color: black;
  &.item {
    color: red;
  }
}
Attempts:
2 left
💡 Hint
Remember that CSS nesting uses the & symbol to refer to the parent selector.
📝 Syntax
intermediate
2:00remaining
Using CSS Variables with calc() instead of SASS variables
Given the SASS code below, which CSS code correctly uses CSS custom properties and calc() to achieve the same dynamic spacing?

$base-spacing: 1rem;
.container {
  padding: $base-spacing * 2;
}
A
.container {
  padding: calc(1rem * 2);
}
B
:root {
  --base-spacing: 1rem;
}
.container {
  padding: var(--base-spacing) * 2;
}
C
:root {
  --base-spacing: 1rem;
}
.container {
  padding: calc(var(--base-spacing) * 2);
}
D
.container {
  padding: 2rem;
}
Attempts:
2 left
💡 Hint
CSS variables require var() and calc() for arithmetic.
selector
advanced
2:30remaining
Which CSS selector replicates SASS @at-root behavior?
SASS's @at-root allows styles to be placed outside the current nesting. Which CSS selector technique can replicate this behavior in future CSS?

Consider this SASS:
.card {
  &__title {
    @at-root {
      .highlight {
        color: blue;
      }
    }
  }
}
A
.card__title:has(.highlight) {
  color: blue;
}
B
.card__title .highlight {
  color: blue;
}
C
:is(.card__title) :where(.highlight) {
  color: blue;
}
D
.card__title {}
.highlight {
  color: blue;
}
Attempts:
2 left
💡 Hint
Think about how to write styles outside the nested selector.
layout
advanced
3:00remaining
Replacing SASS Mixins with CSS @layer and Custom Properties
SASS mixins allow reusable style blocks. Which CSS feature below best replaces mixins for managing reusable styles with layering and variables?

Choose the CSS code that uses @layer and custom properties to create a reusable button style.
A
@mixin btn-style {
  padding: 1rem;
  background: blue;
  color: white;
}
.btn {
  @include btn-style;
}
.btn-primary {
  background: green;
}
B
@layer buttons {
  .btn {
    padding: var(--btn-padding, 1rem);
    background: var(--btn-bg, blue);
    color: white;
  }
}

.btn-primary {
  --btn-bg: green;
}
C
.btn {
  padding: 1rem;
  background: blue;
  color: white;
}
.btn-primary {
  background: green;
}
D
.btn {
  @apply padding: 1rem; background: blue; color: white;
}
.btn-primary {
  background: green;
}
Attempts:
2 left
💡 Hint
Look for CSS features that support layering and variables for reuse.
accessibility
expert
3:00remaining
Ensuring Accessibility with Future CSS Features Replacing SASS
When replacing SASS color functions like darken() with CSS custom properties and color-mix(), which option ensures the best accessibility by maintaining sufficient contrast for text on backgrounds?

Assume --primary-color is a blue shade.
Acolor: color-mix(in srgb, var(--primary-color) 80%, black 20%);
Bcolor: color-mix(in srgb, var(--primary-color) 20%, black 80%);
Ccolor: var(--primary-color);
Dcolor: darken(var(--primary-color), 20%);
Attempts:
2 left
💡 Hint
Higher percentage of primary color keeps the color lighter and more readable.