Bird
Raised Fist0
SASSmarkup~20 mins

Future CSS features replacing SASS - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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.

Practice

(1/5)
1. Which future CSS feature allows you to store reusable values like colors or sizes directly in CSS without using SASS variables?
easy
A. CSS Modules
B. CSS Custom Properties (variables)
C. CSS Functions
D. CSS Mixins

Solution

  1. Step 1: Understand CSS Custom Properties

    CSS Custom Properties let you define variables using the syntax --name: value; inside selectors.
  2. Step 2: Compare with SASS variables

    SASS variables are replaced by CSS Custom Properties which work natively in browsers and can be reused.
  3. Final Answer:

    CSS Custom Properties (variables) -> Option B
  4. Quick Check:

    Variables in CSS = CSS Custom Properties [OK]
Hint: Remember CSS variables start with double dashes -- [OK]
Common Mistakes:
  • Confusing CSS Mixins with variables
  • Thinking CSS Functions are variables
  • Assuming CSS Modules are variables
2. Which of the following is the correct syntax for nesting selectors using future CSS features (without SASS)?
easy
A. nav { ul { list-style: none; } }
B. nav > ul { list-style: none; }
C. nav { & ul { list-style: none; } }
D. nav ul { list-style: none; }

Solution

  1. Step 1: Understand future CSS nesting syntax

    Future CSS uses the & nesting selector to nest selectors, e.g., nav { & ul { list-style: none; } }.
  2. Step 2: Compare with SASS nesting

    SASS allows direct nesting like nav { ul { ... } }, but future CSS requires & or pseudo-classes like :is() or :where().
  3. Final Answer:

    nav { & ul { list-style: none; } } -> Option C
  4. Quick Check:

    Nesting in CSS uses & or :is()/:where() [OK]
Hint: Future CSS nesting uses & nesting selector [OK]
Common Mistakes:
  • Using SASS style nesting directly (without &)
  • Confusing child selector > with nesting
  • Using descendant selector without nesting
3. What will be the computed background color of the <div> in this CSS using future CSS variables?
:root { --main-color: coral; } div { background-color: var(--main-color); }
medium
A. var(--main-color)
B. transparent
C. black
D. coral

Solution

  1. Step 1: Identify the variable definition

    The variable --main-color is set to coral in the :root selector, making it global.
  2. Step 2: Apply the variable in div

    The div uses background-color: var(--main-color); which fetches the value coral.
  3. Final Answer:

    coral -> Option D
  4. Quick Check:

    CSS variable value applied = coral [OK]
Hint: var() fetches the value of CSS custom properties [OK]
Common Mistakes:
  • Thinking var() outputs the variable name
  • Assuming default color if variable is defined
  • Confusing transparent with variable usage
4. Identify the error in this future CSS code snippet that tries to use nesting:
section { article { padding: 1rem; } }
medium
A. Nesting must use & or :is() or :where()
B. The ampersand (&) is not supported in future CSS nesting
C. Incorrect property name 'padding'
D. Missing semicolon after padding value

Solution

  1. Step 1: Check nesting syntax in future CSS

    Future CSS requires nested selectors to start with & or pseudo-classes like :is() or :where(). Plain article is invalid.
  2. Step 2: Identify correct nesting method

    Correct would be section { & article { padding: 1rem; } } or using pseudo-classes.
  3. Final Answer:

    Nesting must use & or :is() or :where() -> Option A
  4. Quick Check:

    Future CSS nesting requires & or pseudo-classes [OK]
Hint: Future CSS nesting requires & or :is()/:where() [OK]
Common Mistakes:
  • Using plain selectors without & or pseudo-class
  • Ignoring missing semicolon which is correct here
  • Confusing property names
5. You want to create a responsive design using future CSS features replacing SASS. Which is the correct way to write a media query that changes font size for screens wider than 600px?
medium
A. @media screen and (min-width: 600px) { body { font-size: 1.2rem; } }
B. @media (min-width: 600px) { body { font-size: 12; } }
C. @media screen (min-width: 600px) { body { font-size: 1.2rem; } }
D. @media (min-width: 600) { body { font-size: 1.2rem; } }

Solution

  1. Step 1: Understand media query syntax

    Future CSS uses standard CSS media queries. The correct syntax includes the media type, e.g., screen and (min-width: 600px).
  2. Step 2: Check font size units

    Using 1.2rem is better for accessibility and scaling than fixed pixels.
  3. Final Answer:

    @media screen and (min-width: 600px) { body { font-size: 1.2rem; } } -> Option A
  4. Quick Check:

    Media query with screen and rem units [OK]
Hint: Always include media type and use rem units for fonts [OK]
Common Mistakes:
  • Omitting 'and' after media type 'screen'
  • Using px instead of rem for font size
  • Missing 'px' unit in media query