Why Extending Reduces Duplication in Sass
📖 Scenario: You are creating styles for a website with multiple button types. Many buttons share common styles, but each also has unique colors. Instead of repeating the shared styles for each button, you will use Sass @extend to reduce duplication.
🎯 Goal: Build Sass code that uses @extend to share common button styles among different button classes, reducing repeated CSS rules.
📋 What You'll Learn
Create a base button style class with common properties
Create a variable for the primary color
Use
@extend to apply base styles to specific button classesAdd unique background colors to each button class
💡 Why This Matters
🌍 Real World
Web developers often style many similar elements like buttons. Using @extend helps keep CSS clean and easier to maintain by sharing common styles.
💼 Career
Knowing how to reduce duplication in stylesheets is important for front-end developers to write efficient, scalable CSS or Sass code.
Progress0 / 4 steps