Component
The reusable object: card, button, nav, modal.
Class names are communication. A good class name tells future developers what a thing is, not just how it looks today.
.course-card {}
.course-card__title {}
.course-card--featured {}
.course-card.is-selected {}
Architecture mental model
CSS class names are a contract between HTML and CSS. Once a class name spreads through templates, changing it becomes real work.
A useful name describes the component, part, state or utility. A weak name describes one temporary visual detail that may change next week.
You do not need to use BEM exactly, but you do need a naming system that is consistent enough to scale.
The reusable object: card, button, nav, modal.
A part that belongs to the component: card__title.
A variation: card--featured or button--primary.
Current behavior: is-active, is-open or data-state.
Visual model
The standalone component.
A named part inside the block.
A variation of the block.
Temporary UI state, not permanent identity.
Good CSS versus fragile CSS
.course-card {}
.course-card__title {}
.course-card__meta {}
.course-card--featured {}
.course-card.is-selected {}
.blue-box {}
.big-text2 {}
.new-card-final {}
.leftthing {}
Rules of thumb
Use the component purpose rather than a temporary color or size.
A simple consistent pattern beats three naming philosophies in one project.
A clear class name is better than long descendant selectors.
is-active describes current state; nav-link describes what the element is.
new, final and v2 become lies quickly.
A class name should be easy to find in templates and CSS.
Production thinking
Names are how a project remembers its own structure. Bad names make CSS feel random even when the declarations are correct.
State classes should match accessible states where relevant. If something is open visually, aria-expanded should usually agree.
Document the naming convention in the project README before multiple developers start inventing their own.
Class names are not SEO content, but a maintainable frontend makes it easier to keep semantic HTML clean.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If you cannot find, name or move a rule safely, the architecture still needs work.
Senior audit upgrade
Even if a project uses utilities, component names still communicate purpose, boundaries and state.
.blue-box says less than .pricing-card.
Deep class chains make components hard to move.
Use clear state hooks such as .is-open or data-state="open".