Combining & with BEM naming in Sass
📖 Scenario: You are creating a simple card component for a website. The card has a block called card, and inside it, there is an element called title. You want to style the card and its title using Sass with BEM naming conventions.
🎯 Goal: Build Sass styles using the & symbol combined with BEM naming to style the card block and its title element.
📋 What You'll Learn
Create a Sass block selector named
.cardCreate a Sass variable called
$title-color with the value #2a9d8fUse the
& symbol combined with BEM naming to style the .card__title element inside the .card blockSet the color of
.card__title to the Sass variable $title-color💡 Why This Matters
🌍 Real World
Using BEM naming with Sass nesting helps keep CSS organized and easy to maintain in real web projects.
💼 Career
Front-end developers often use Sass and BEM to write scalable and clean CSS for websites and apps.
Progress0 / 4 steps