Recall & Review
beginner
What does the
@else directive do in Sass?The
@else directive runs a block of styles only if the previous @if or @else if condition was false. It acts like the "otherwise" case in decision making.Click to reveal answer
beginner
How is
@else if different from @else in Sass?@else if lets you check another condition if the previous @if or @else if was false. @else runs only if all previous conditions were false, without checking a new condition.Click to reveal answer
beginner
Write a simple Sass example using
@if, @else if, and @else.$color: blue;
@if $color == red {
background: red;
} @else if $color == blue {
background: blue;
} @else {
background: gray;
}
This sets background color based on the value of
$color.Click to reveal answer
intermediate
Can you have multiple
@else if branches in Sass?Yes, you can chain many
@else if branches to check multiple conditions one after another before falling back to @else.Click to reveal answer
beginner
What happens if none of the
@if or @else if conditions are true and there is no @else?No styles inside the conditional blocks will be applied. The Sass code inside those blocks is skipped.
Click to reveal answer
What does
@else do in Sass?✗ Incorrect
@else runs its block only when all previous conditions are false.Which directive lets you check another condition after an
@if in Sass?✗ Incorrect
@else if lets you test another condition if the previous @if was false.Can you use multiple
@else if branches in Sass?✗ Incorrect
Sass allows multiple
@else if branches to check many conditions.What happens if no conditions match and there is no
@else?✗ Incorrect
If no conditions match and no
@else exists, no styles inside those blocks are applied.Which of these is the correct syntax for
@else if in Sass?✗ Incorrect
The correct syntax is
@else if condition { }.Explain how
@else if and @else work together in Sass conditional statements.Think of it like a decision tree with multiple branches.
You got /4 concepts.
Write a Sass snippet using
@if, @else if, and @else to set a background color based on a variable.Use $color variable and compare it to color names.
You got /5 concepts.