0
0
SASSmarkup~20 mins

Why extending reduces duplication in SASS - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sass Extend Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why does @extend reduce duplication in Sass?
Consider the Sass code below. What is the main reason using @extend reduces duplication in the compiled CSS?
SASS
%button-base {
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  font-weight: bold;
}

.btn-primary {
  @extend %button-base;
  background-color: blue;
  color: white;
}
ABecause @extend creates new CSS classes for each use, adding more code.
BBecause @extend duplicates all styles into each selector, increasing file size.
CBecause @extend removes all styles from the original selector, leaving it empty.
DBecause @extend merges selectors sharing the same styles, so the CSS rules appear only once.
Attempts:
2 left
💡 Hint
Think about how CSS selectors combine when using @extend.
📝 Syntax
intermediate
2:00remaining
What is the output CSS from this Sass using @extend?
Given the Sass code below, what is the compiled CSS output?
SASS
%alert {
  padding: 1rem;
  border: 1px solid red;
}

.error {
  @extend %alert;
  background-color: pink;
}

.warning {
  @extend %alert;
  background-color: yellow;
}
A
.error, .warning {
  padding: 1rem;
  border: 1px solid red;
}
.error {
  background-color: pink;
}
.warning {
  background-color: yellow;
}
B
.error {
  padding: 1rem;
  border: 1px solid red;
  background-color: pink;
}
.warning {
  padding: 1rem;
  border: 1px solid red;
  background-color: yellow;
}
C
%alert {
  padding: 1rem;
  border: 1px solid red;
}
.error {
  background-color: pink;
}
.warning {
  background-color: yellow;
}
D
.error, .warning {
  background-color: pink;
  padding: 1rem;
  border: 1px solid red;
}
Attempts:
2 left
💡 Hint
Look at how selectors combine when extending a placeholder.
selector
advanced
2:00remaining
Which selector combination results from this Sass @extend?
What is the combined selector in the compiled CSS after this Sass code runs?
SASS
%card {
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
  padding: 1rem;
}

.profile-card {
  @extend %card;
  border-radius: 0.5rem;
}

.product-card {
  @extend %card;
  border-radius: 1rem;
}
A.profile-card, .product-card
B%card, .profile-card, .product-card
C.profile-card.product-card
D.profile-card .product-card
Attempts:
2 left
💡 Hint
Think about how @extend merges selectors sharing the same styles.
layout
advanced
2:00remaining
How does @extend affect CSS file size and layout performance?
Which statement best describes the impact of using @extend on CSS file size and browser layout performance?
A@extend has no effect on CSS file size or browser performance.
B@extend reduces CSS file size by combining selectors, which can improve browser rendering speed.
C@extend increases CSS file size by duplicating styles, slowing down browser layout.
D@extend removes all styles from extended selectors, causing layout issues.
Attempts:
2 left
💡 Hint
Consider how fewer repeated styles affect file size and rendering.
accessibility
expert
3:00remaining
How can @extend misuse affect accessibility in CSS?
Which scenario shows how incorrect use of @extend might unintentionally harm accessibility?
AExtending color contrast styles to multiple elements, improving readability.
BExtending a button style into a link, making it keyboard accessible.
CExtending a visually hidden class into a visible element, causing it to be hidden from screen readers.
DExtending focus styles to all interactive elements, enhancing keyboard navigation.
Attempts:
2 left
💡 Hint
Think about how styles that hide content affect screen readers.