Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

CSS Architecture – BEM, OOCS | CSS Basics to Advanced lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Basics to Advanced

Lesson 39 of 50

·css

CSS Architecture – BEM, OOCSS, SMACSS, ITCSS

12 mins

Course progress78%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Choose **one** methodology and stick to it across a project.
  • Avoid **over‑specific selectors**; keep specificity low.
  • Group related styles (base, layout, component) in separate files or sections.

A solid CSS architecture keeps styles predictable, reusable, and scalable.

MethodCore IdeaWhen to Use
BEMBlock __ Element -- Modifier (e.g., .card__title--large).Component‑heavy UI libraries, large teams.
OOCSSSeparate structure (layout) from skin (visuals).When you notice many elements sharing the same box model.
SMACSSCategorises rules: Base, Layout, Module, State, Theme.Projects that need a clear layer distinction.
ITCSSInverted Triangle – from generic to explicit (variables → utilities → components → trumps).Large, complex code‑bases where cascade order matters a lot.

Example – BEM Button

<button class="btn btn--primary">Click me</button>
/* Block */
.btn { padding:0.6rem 1.2rem; border:none; cursor:pointer; }
/* Modifier */
.btn--primary { background:#0066cc; color:#fff; }
/* Element (if needed) */
.btn__icon { margin-right:0.5rem; }

OOCSS – Object + Skin

/* Object – reusable layout */
.media { display:flex; align-items:center; }
/* Skin – colour, typographic tweaks */
.media--highlight { background:#fffae6; }

SMACSS Layout Example

/* Layout */
.l-header { grid-area:header; }
.l-main   { grid-area:main; }
.l-footer { grid-area:footer; }
/* Module */
.card { border:1px solid #e0e0e0; }
/* State */
.is-active { opacity:1; }
/* Theme */
.theme-dark .card { background:#111; color:#eee; }

ITCSS Layer Order (high‑level view)

  1. Settings – Variables & globals.
  2. Tools – Mixins, functions, utilities.
  3. Generic – Reset/normalize.
  4. Elements – Base HTML styling.
  5. Objects – Reusable layout blocks.
  6. Components – UI widgets.
  7. Utilities – Helper classes (e.g., .u-hidden).
  8. Trumps – Overrides (!important).

Choosing a Strategy

  • Start simple – BEM works well for most front‑end teams.
  • Scale up – When the project grows, migrate towards ITCSS to better control cascade order.
  • Document – Keep a living style guide (Storybook, Styleguidist) so new contributors understand the conventions.

Real‑World Tip – Keep Specificity Low

If you rely on BEM correctly, your selectors will never exceed one‑class specificity, avoiding cascade battles.

Accessibility Check

Never use a trump class to hide content (.is-hidden { display:none; }) without also handling focus management; otherwise keyboard users may get trapped.

Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS Basics to AdvancedBrowse activities
Previous lessonCSS Performance – Critical CSS & Unused CSSContinue to lesson 40CSS Pre‑processors – Sass & LessBack to CSS Basics to Advanced curriculum