0
0
SASSmarkup~20 mins

Extending vs mixing comparison in SASS - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Extending vs Mixing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference in CSS output size between @extend and @mixin
Consider the following Sass code snippets. Which option correctly describes the difference in the compiled CSS size when using @extend versus @mixin?
SASS
@mixin button-style {
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  background-color: blue;
  color: white;
}

.button1 {
  @extend .base-button;
}

.button2 {
  @include button-style;
}
AUsing <code>@extend</code> creates one combined CSS rule shared by all selectors, reducing CSS size; <code>@mixin</code> duplicates styles for each use, increasing CSS size.
B<code>@extend</code> removes all styles from the original selector; <code>@mixin</code> keeps styles only in the mixin definition.
CBoth <code>@extend</code> and <code>@mixin</code> always produce identical CSS size regardless of usage.
D<code>@extend</code> duplicates styles for each selector, increasing CSS size; <code>@mixin</code> creates one combined CSS rule shared by all selectors, reducing CSS size.
Attempts:
2 left
💡 Hint
Think about how @extend merges selectors in the output CSS.
📝 Syntax
intermediate
1:30remaining
Correct syntax to include a mixin with parameters
Which option shows the correct way to define and include a mixin with a parameter $color in Sass?
SASS
@mixin colored-text($color) {
  color: $color;
}

.text {
  /* include mixin here */
}
A@extend colored-text(blue);
B@mixin colored-text(blue);
C@include colored-text;
D@include colored-text(blue);
Attempts:
2 left
💡 Hint
Remember that @include is used to call mixins.
rendering
advanced
2:30remaining
Visual difference when using @extend vs @mixin for hover styles
Given these Sass snippets, which compiled CSS will produce a hover effect only on .button and not on .link?
SASS
// Using @extend
.button {
  @extend %hover-style;
}
.link {
  @extend %hover-style;
}

%hover-style {
  &:hover {
    color: red;
  }
}

// Using @mixin
@mixin hover-style {
  &:hover {
    color: red;
  }
}

.button {
  @include hover-style;
}
.link {
  // no hover style included
}
AThe @mixin version applies hover only to .button; the @extend version applies hover to both .button and .link.
BThe @extend version applies hover only to .button; the @mixin version applies hover to both .button and .link.
CBoth versions apply hover to only .button.
DNeither version applies hover to any element.
Attempts:
2 left
💡 Hint
Check which selectors get combined in the compiled CSS for @extend.
selector
advanced
2:00remaining
Selector specificity when using @extend with multiple selectors
If you have this Sass code, what will be the compiled CSS selector for .alert after extending .message, .notification?
SASS
.message, .notification {
  border: 1px solid black;
}

.alert {
  @extend .message, .notification;
}
A.alert { border: 1px solid black; }
B.message, .notification, .alert { border: 1px solid black; }
C.message.alert, .notification.alert { border: 1px solid black; }
D.message, .notification { border: 1px solid black; }
Attempts:
2 left
💡 Hint
Think about how @extend merges selectors in the output.
accessibility
expert
3:00remaining
Accessibility impact of using @extend vs @mixin for focus styles
Which statement best explains the accessibility impact when using @extend versus @mixin for focus styles on interactive elements?
ABoth <code>@extend</code> and <code>@mixin</code> have no impact on accessibility because styles do not affect keyboard navigation.
B<code>@mixin</code> always removes focus styles, reducing accessibility; <code>@extend</code> ensures focus styles are applied correctly.
C<code>@extend</code> can unintentionally apply focus styles to unrelated elements sharing selectors, possibly confusing keyboard users; <code>@mixin</code> scopes styles only where included, improving accessibility.
D<code>@extend</code> duplicates focus styles for each element, causing flickering; <code>@mixin</code> merges focus styles into one rule.
Attempts:
2 left
💡 Hint
Consider how selectors are combined and how that affects which elements get focus styles.