Bird
Raised Fist0
SASSmarkup~10 mins

First SASS stylesheet - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a variable for the main color.

SASS
$main-color: [1];
Drag options to blanks, or click blank then click option'
A#3498db
Bcolor
Cmain-color
Dblue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name instead of a color value.
Forgetting the semicolon at the end.
2fill in blank
medium

Complete the code to use the variable $main-color for the background color.

SASS
body {
  background-color: [1];
}
Drag options to blanks, or click blank then click option'
A$main-color
Bmain-color
C#fff
Dbackground
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the $ sign before the variable.
Using a color value directly instead of the variable.
3fill in blank
hard

Fix the error in the nested style by completing the selector for the h1 inside header.

SASS
header {
  background: $main-color;
  [1] {
    color: white;
  }
}
Drag options to blanks, or click blank then click option'
A.h1
Bh1
C#h1
Dheader h1
Attempts:
3 left
💡 Hint
Common Mistakes
Using class or id selectors instead of element selectors.
Repeating the parent selector inside the nested block.
4fill in blank
hard

Fill both blanks to create a nested style for nav inside header with a hover effect on links.

SASS
header {
  [1]: $main-color;
  nav {
    a {
      color: white;
      &:[2] {
        color: #f39c12;
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abackground
Bhover
Cactive
Dborder
Attempts:
3 left
💡 Hint
Common Mistakes
Using border instead of background for color.
Using active instead of hover for mouse hover effect.
5fill in blank
hard

Fill all three blanks to create a SASS map of colors and use it to set the border color.

SASS
$colors: (
  primary: [1],
  secondary: [2]
);

.box {
  border: 2px solid map-get($colors, [3]);
}
Drag options to blanks, or click blank then click option'
A#2980b9
B#2ecc71
Cprimary
Dsecondary
Attempts:
3 left
💡 Hint
Common Mistakes
Using color values as keys instead of keys as strings.
Forgetting to use map-get to access map values.

Practice

(1/5)
1. What is the main benefit of using variables in a SASS stylesheet?
easy
A. They automatically fix CSS errors.
B. They make the stylesheet load faster in the browser.
C. They let you reuse values like colors and sizes easily.
D. They convert SASS to JavaScript.

Solution

  1. Step 1: Understand what variables do in SASS

    Variables store values such as colors or sizes so you can reuse them without repeating the same value.
  2. Step 2: Compare options with this understanding

    Only They let you reuse values like colors and sizes easily. correctly describes this benefit. Other options describe unrelated or incorrect features.
  3. Final Answer:

    They let you reuse values like colors and sizes easily. -> Option C
  4. Quick Check:

    Variables store reusable values = A [OK]
Hint: Variables store reusable values like colors or sizes [OK]
Common Mistakes:
  • Thinking variables speed up browser loading
  • Believing variables fix CSS errors automatically
  • Confusing SASS variables with JavaScript
2. Which of the following is the correct way to declare a variable in SASS?
easy
A. $main-color: #3498db;
B. var main-color = #3498db;
C. main-color: #3498db;
D. @main-color: #3498db;

Solution

  1. Step 1: Recall SASS variable syntax

    In SASS, variables start with a dollar sign ($) followed by the name, then a colon and the value.
  2. Step 2: Match options to this syntax

    $main-color: #3498db; matches this exactly. Options B, C, and D use incorrect syntax.
  3. Final Answer:

    $main-color: #3498db; -> Option A
  4. Quick Check:

    Variables start with $ in SASS = A [OK]
Hint: Variables always start with $ in SASS [OK]
Common Mistakes:
  • Using var keyword like JavaScript
  • Omitting the $ sign before variable name
  • Using @ instead of $ for variables
3. What will be the output CSS of this SASS code?
$primary-color: #ff0000;

.button {
  color: $primary-color;
  &:hover {
    color: darken($primary-color, 20%);
  }
}
medium
A. .button { color: $primary-color; } .button:hover { color: darken($primary-color, 20%); }
B. Syntax error: darken function not recognized
C. .button { color: #ff0000; } .button:hover { color: #ff3333; }
D. .button { color: #ff0000; } .button:hover { color: #cc0000; }

Solution

  1. Step 1: Understand variable substitution and nesting

    The variable $primary-color is replaced with #ff0000. The nested &:hover becomes .button:hover.
  2. Step 2: Calculate darken color

    darken(#ff0000, 20%) makes the red darker, resulting in #cc0000.
  3. Final Answer:

    .button { color: #ff0000; } .button:hover { color: #cc0000; } -> Option D
  4. Quick Check:

    Variables replaced and nesting expanded = B [OK]
Hint: Variables replaced, nesting expands selectors [OK]
Common Mistakes:
  • Leaving variables as-is in output CSS
  • Not expanding nested selectors
  • Misunderstanding darken color function
4. Identify the error in this SASS code:
$font-size: 16px

body {
  font-size: $font-size;
}
medium
A. body selector cannot be used in SASS
B. Missing semicolon after variable declaration
C. font-size property is invalid
D. Variable name should not start with $

Solution

  1. Step 1: Check variable declaration syntax

    In SASS, each statement must end with a semicolon. The variable declaration lacks a semicolon.
  2. Step 2: Verify other parts

    Variable names start with $, font-size is valid, and body selector is allowed.
  3. Final Answer:

    Missing semicolon after variable declaration -> Option B
  4. Quick Check:

    Semicolon missing after $font-size declaration = D [OK]
Hint: Always end variable declarations with semicolon [OK]
Common Mistakes:
  • Omitting semicolon after variable
  • Thinking $ is invalid for variables
  • Assuming selectors can't be used
5. You want to create a SASS stylesheet where all buttons have a background color stored in a variable, and on hover, the background becomes 15% lighter. Which SASS code correctly achieves this?
hard
A. $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: lighten($btn-bg, 15%); } }
B. $btn-bg: #007bff button { background-color: $btn-bg; &:hover { background-color: lighten($btn-bg, 15%) } }
C. $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: darken($btn-bg, 15%); } }
D. $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: $btn-bg + 15%; } }

Solution

  1. Step 1: Check variable declaration and syntax

    $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: lighten($btn-bg, 15%); } } correctly declares $btn-bg with a semicolon and uses proper nesting with &:hover.
  2. Step 2: Verify color function usage

    $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: lighten($btn-bg, 15%); } } uses lighten($btn-bg, 15%) to make the color lighter on hover, which matches the requirement.
  3. Step 3: Identify errors in other options

    $btn-bg: #007bff button { background-color: $btn-bg; &:hover { background-color: lighten($btn-bg, 15%) } } misses semicolons; $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: darken($btn-bg, 15%); } } darkens instead of lightens; $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: $btn-bg + 15%; } } tries invalid addition of color and percentage.
  4. Final Answer:

    $btn-bg: #007bff; button { background-color: $btn-bg; &:hover { background-color: lighten($btn-bg, 15%); } } -> Option A
  5. Quick Check:

    Correct variable, nesting, and lighten function = C [OK]
Hint: Use lighten() with correct syntax and semicolons [OK]
Common Mistakes:
  • Forgetting semicolons after declarations
  • Using darken instead of lighten
  • Trying to add percentage directly to color
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard