
What is BEM, SMACSS and Atomic CSS, and how they are diferent?
If you’ve ever stared at a tangled mess of CSS and thought “there has to be a better way”, you’re not alone. I recently went down the rabbit hole of CSS methodologies: BEM, SMACSS and Atomic CSS. Here’s my breakdown of what they are, how they differ, and what they taught me about writing styles that don’t come back to haunt me.
🧱 BEM: Block Element Modifier
BEM stands for Block, Element, Modifier. It’s a naming convention to help you write clear, predictable CSS. Structure:
.block {} .block__element {} .block--modifier {}
Example:
<article class="card card--highlighted">
<h2 class="card__title">Oferta especial</h2> <p class="card__text">Aprovecha ahora</p> </article>
Why use BEM? * You can move or refactor components without breaking other styles. * It’s like labeling every drawer in your CSS kitchen. * Perfect for big teams or long-term projects.
Drawbacks: * Verbose class names. * May feel like overkill for small components or rapid prototyping.
🧠 SMACSS: Scalable and Modular Architecture for CSS
SMACSS is more a way of organizing styles than naming them. It breaks your CSS into 5 categories:
- Base – Global resets and bare tags (
html
,a
,body
) - Layout – Structure of the page (
.l-header
,.l-footer
) - Module – Reusable components (
.card
,.btn
,.nav
) - State – Variants and toggles (
.is-active
,.is-open
) - Theme – Visual skins or brand styles
Example:
<nav class="nav">
<ul class="nav__list">
<li class="nav__item is-active"><a href="#">Home</a></li>
</ul>
</nav>
Why use SMACSS? * Forces you to think in categories, not just names. * Great for large-scale projects that need clear separation of concerns. * Mixes well with other systems like BEM or utility helpers. Downsides? * No strict naming—requires team discipline. * Less intuitive than BEM until you get used to it.
⚛️ Atomic CSS / Utility-first CSS
Atomic CSS is about writing classes that do exactly one thing:
<div class="p-4 bg-blue-500 text-white font-bold">
I'm styled using atomic utilities.
</div>
Each class = one job: * p-4
→ padding: 1rem * bg-blue-500
→ background-color: #3b82f6 * text-white
→ color: white * font-bold
→ font-weight:
700 Popular frameworks like Tailwind CSS, Windi CSS, and UnoCSS follow this model.
Pros:
- Ridiculously fast prototyping.
- No cascade conflicts.
- Small final bundle with tools like PurgeCSS.
- Fully responsive and state-ready (
hover:
,md:
, etc.)
Cons:
- Markup can get noisy: lots of classes everywhere. * Requires design system discipline or it gets messy fast. * HTML is no longer “semantic” at a glance.
🤔 Isn’t Atomic CSS just like using inline styles?
Almost! But here’s the critical difference:
Feature | Inline Styles (style="" ) | Atomic CSS Classes |
---|---|---|
Reusable | ❌ No | ✅ Yes |
Cacheable | ❌ No | ✅ Yes |
Theming | ❌ Painful | ✅ Built-in (with variables, dark mode, etc.) |
States (hover, focus) | ❌ Needs JS | ✅ Comes out of the box |
Specificity | 🔥 Super high | ✅ Manageable |
Inline styles are like tattoos: fast, permanent, hard to override. Atomic classes are like Lego blocks: reusable, flexible, easy to swap.
🧭 So… which one should you use?
BEM is great for:
- Long-lived, structured apps
- Teams with multiple devs
- Keeping things semantic
SMACSS is great for:
- Big projects that need order
- Devs who prefer categorization over naming rules
Atomic CSS is great for:
- Rapid development
- Design systems
- Devs who love speed and control
💡 Final Thoughts
All three have something valuable to teach. Personally, Atomic CSS feels good for,and I started using it when I discover TailwindCSS. It’s not “one size fits all,” but if you understand the tradeoffs, you’ll write better CSS no matter what you choose. Let your context and your team guide you. And please, for the love of maintainability: just don’t mix all three without a plan.
Thanks for reading! If this article helped you untangle some CSS spaghetti, consider sharing it with a teammate—or your future self. 🤓 ```
Note: This article was written with help of ChatGPT, is the result of me asking some questions I din’t know, if you find an error in the information please let me know so I can fix it at diego27796gagan@gmail.com.