0
0
SASSmarkup~20 mins

Reducing compiled CSS size in SASS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS Size Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use variables in Sass to reduce CSS size?
Using variables in Sass helps reduce the compiled CSS size because:
AVariables allow reusing values, so the compiler can optimize repeated values into shorter CSS.
BVariables convert all colors to hex codes, which are shorter than named colors.
CVariables automatically compress CSS by removing spaces and comments.
DVariables inline all styles, increasing CSS size but improving speed.
Attempts:
2 left
💡 Hint
Think about how repeating the same value many times affects file size.
📝 Syntax
intermediate
2:00remaining
What is the output CSS from this Sass code?
Given this Sass code, what is the compiled CSS output?
SASS
$primary-color: #3498db;

.button {
  color: $primary-color;
  border: 1px solid $primary-color;
}
A
.button {
  color: #3498db;
  border: 1px solid #3498db;
}
B
.button {
  color: $primary-color;
  border: 1px solid $primary-color;
}
C
.button {
  color: blue;
  border: 1px solid blue;
}
D
.button {
  color: #3498db;
  border: 1px solid blue;
}
Attempts:
2 left
💡 Hint
Sass replaces variables with their values in the compiled CSS.
selector
advanced
2:00remaining
Which Sass selector nesting reduces compiled CSS size the most?
Consider these Sass snippets. Which one produces the smallest compiled CSS?
A
.nav {
  ul {
    margin: 0;
  }
  li {
    list-style: none;
  }
}
B
.nav ul {
  margin: 0;
}
.nav li {
  list-style: none;
}
C
.nav > ul {
  margin: 0;
}
.nav > li {
  list-style: none;
}
D
ul.nav {
  margin: 0;
}
li.nav {
  list-style: none;
}
Attempts:
2 left
💡 Hint
Look at how nesting affects the selectors in the compiled CSS.
layout
advanced
2:00remaining
How does using Flexbox in Sass affect compiled CSS size?
Which statement about using Flexbox properties in Sass to reduce CSS size is true?
AFlexbox always increases CSS size because it requires many properties.
BSass automatically removes unused Flexbox properties to reduce size.
CUsing shorthand Flexbox properties in Sass reduces compiled CSS size by combining multiple properties.
DUsing Flexbox in Sass requires writing all properties separately, increasing CSS size.
Attempts:
2 left
💡 Hint
Think about how shorthand properties work in CSS.
accessibility
expert
3:00remaining
Which Sass approach best supports accessible color contrast while minimizing CSS size?
You want to ensure text colors meet accessibility contrast standards but keep your compiled CSS small. Which Sass method is best?
AHardcode all colors directly in selectors without variables to minimize Sass processing.
BWrite separate CSS classes for each color contrast level without variables to keep code simple.
CUse inline styles in HTML for accessibility and avoid Sass variables to reduce CSS size.
DDefine color variables and use Sass functions to adjust contrast dynamically, reusing variables to avoid repetition.
Attempts:
2 left
💡 Hint
Think about reusing values and dynamic adjustments in Sass.