BEM Naming with SASS Nesting
📖 Scenario: You are creating styles for a simple card component on a webpage. The card has a title, a description, and a button. You want to use the BEM naming method to keep your CSS organized and easy to read.
🎯 Goal: Build a SASS stylesheet using BEM naming conventions with nesting to style a card component. The card block is card. It has elements __title, __description, and __button. The button also has a modifier --primary for a special style.
📋 What You'll Learn
Create a SASS block selector for
.card.Nest element selectors for
.card__title, .card__description, and .card__button inside .card.Nest a modifier selector
.card__button--primary inside .card__button.Use nesting to keep the code clean and follow BEM naming exactly.
💡 Why This Matters
🌍 Real World
Using BEM with SASS nesting helps keep CSS organized and easy to maintain in real web projects with many components.
💼 Career
Front-end developers often use BEM and SASS nesting to write scalable and readable stylesheets for websites and apps.
Progress0 / 4 steps