Why Variables Reduce Repetition in Sass
📖 Scenario: You are creating a simple style sheet for a website. You want to use the same color and font size in many places. Instead of writing the color and font size again and again, you will use variables to store these values once and reuse them.
🎯 Goal: Build a Sass file that uses variables to store a color and a font size. Then use these variables in multiple CSS rules to style headings and paragraphs.
📋 What You'll Learn
Create a variable called
$main-color with the value #3498dbCreate a variable called
$main-font-size with the value 1.5remUse
$main-color for the color of h1 and h2 elementsUse
$main-font-size for the font size of p elements💡 Why This Matters
🌍 Real World
Web designers use variables to keep their color schemes and fonts consistent across many pages.
💼 Career
Knowing how to use variables in Sass is important for front-end developers to write clean, maintainable CSS.
Progress0 / 4 steps