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
Why migration to modern SASS matters
📖 Scenario: You work for a small web design team. Your team currently uses old SASS syntax in your stylesheets. You want to show why moving to modern SASS syntax is important for better code and easier maintenance.
🎯 Goal: Create a simple SASS stylesheet using modern SASS features like variables, nesting, and mixins to demonstrate the benefits of migrating from old SASS syntax.
📋 What You'll Learn
Use SASS variables to store colors
Use nesting to organize CSS selectors
Create and use a mixin for reusable styles
Write code using modern SASS syntax (no indented syntax)
💡 Why This Matters
🌍 Real World
Modern SASS helps teams write cleaner, more maintainable CSS for websites and apps.
💼 Career
Knowing modern SASS syntax is valuable for front-end developers working on scalable projects.
Progress0 / 4 steps
1
Set up color variables
Create two SASS variables called $primary-color and $secondary-color with values #3498db and #2ecc71 respectively.
SASS
Hint
Use $variable-name: value; syntax to create variables in SASS.
2
Add nested styles for a button
Create a CSS selector .button and nest inside it a selector for &:hover. Set the background color of .button to $primary-color and the background color of &:hover to $secondary-color.
SASS
Hint
Use nesting by placing &:hover inside .button block.
3
Create a mixin for rounded corners
Create a mixin called rounded-corners that sets border-radius to 0.5rem. Then include this mixin inside the .button selector.
SASS
Hint
Define mixins with @mixin name { } and use them with @include name;.
4
Add a media query with nesting
Inside the .button selector, add a media query for screen widths less than 600px using @media (max-width: 600px). Inside this media query, set the font-size of .button to 1.2rem.
SASS
Hint
Use nesting to place media queries inside selectors for cleaner code.
Practice
(1/5)
1. Why is migrating to modern SASS important for organizing styles?
easy
A. Because modern SASS uses modules to keep code clean and avoid conflicts
B. Because modern SASS removes all CSS features
C. Because modern SASS only works with JavaScript
D. Because modern SASS disables variables
Solution
Step 1: Understand the role of modules in modern SASS
Modern SASS introduces modules to organize styles better and prevent naming conflicts.
Step 2: Compare with old SASS style management
Old SASS mixes all styles globally, causing conflicts and messy code.
Final Answer:
Because modern SASS uses modules to keep code clean and avoid conflicts -> Option A
Quick Check:
Modules improve style organization = D [OK]
Hint: Remember: modules keep styles neat and conflict-free [OK]
Common Mistakes:
Thinking modern SASS removes CSS features
Believing modern SASS only works with JavaScript
Assuming variables are disabled in modern SASS
2. Which of the following is the correct syntax to import a module in modern SASS?
easy
A. @import 'colors';
B. @use 'colors';
C. import colors from 'colors';
D. #use colors;
Solution
Step 1: Identify modern SASS import syntax
Modern SASS uses @use to import modules, replacing @import.
Step 2: Check each option
@use 'colors'; uses @use 'colors'; which is correct. @import 'colors'; uses old syntax. JavaScript-style import and #use are invalid.
Final Answer:
@use 'colors'; -> Option B
Quick Check:
@use is modern import syntax = A [OK]
Hint: Modern SASS imports use '@use', not '@import' [OK]
Common Mistakes:
Using old '@import' instead of '@use'
Trying JavaScript import syntax in SASS
Using invalid symbols like '#use'
3. What will be the output CSS of this modern SASS code?
math.div divides numbers safely in modern SASS; dividing by zero is invalid.
Step 2: Identify the error
math.div($size, 0) causes a division by zero error, which is not allowed.
Final Answer:
Division by zero error in math.div($size, 0) -> Option A
Quick Check:
Division by zero causes error = A [OK]
Hint: Check for zero in math.div to avoid errors [OK]
Common Mistakes:
Thinking 'sass:math' is invalid module
Ignoring division by zero
Assuming missing semicolon causes error
5. You want to migrate old SASS code using @import to modern SASS modules. Which approach correctly updates the code to avoid global namespace conflicts?