Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a variable for the primary color in SASS.
SASS
$primary-color: [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of color values.
Forgetting the '#' in hex color codes.
✗ Incorrect
In SASS, colors are usually defined using hex codes like '#ff6347' for tomato red.
2fill in blank
mediumComplete the mixin to extract critical CSS by limiting styles to above-the-fold content.
SASS
@mixin critical [1] { overflow: hidden; max-height: 600px; }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase instead of simple names.
Using underscores which are less common in SASS mixin names.
✗ Incorrect
Mixin names should be descriptive and 'critical' clearly indicates styles for critical CSS.
3fill in blank
hardFix the error in the nested selector to apply styles only to critical elements.
SASS
.critical-container {
[1] {
display: block;
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting '&' causing invalid nesting.
Using '>' without '&' which is invalid in SASS nesting.
✗ Incorrect
Using '& .critical-content' correctly nests the selector inside '.critical-container' targeting its child.
4fill in blank
hardFill both blanks to create a map of critical CSS selectors and their max heights.
SASS
$critical-map: ( [1]: 600px, [2]: 400px );
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing footer or sidebar which are usually below the fold.
Using invalid selector names.
✗ Incorrect
'.header' and '.hero' are common critical areas above the fold needing height limits.
5fill in blank
hardFill all three blanks to write a function that returns critical CSS selectors with height limits above a threshold.
SASS
@function get-critical-selectors($map, $threshold) {
@return map-filter($map, ($key, $value) => $value [1] $threshold);
}
$filtered: get-critical-selectors($critical-map, [2]);
@include critical {
max-height: [3];
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causing wrong filtering.
Mixing up threshold and max-height values.
✗ Incorrect
The function filters selectors with height greater than threshold 500px, then applies max-height 600px.