Color scheme

CSS Architecture Philosophies

You have already seen how cascade layers let you control which rules win, and how modern selectors keep your specificity flat. Those are the mechanical tools. Architecture is the plan for how you use them. A CSS architecture answers questions like: where does a new rule go, what should each file be responsible for, and how do you keep a growing stylesheet from turning into a tangle of overrides?

Several well known methodologies have tackled this problem over the years. This reading introduces four of them: CUBE CSS, ITCSS, SMACSS, and BEM. Each takes a different angle, but they share the same goal of making CSS predictable and maintainable at scale. After surveying all four, you will see how this course blends the ideas that work best into its own standard.

Explore the Original Sources

This reading gives you an overview of each methodology, but it is not a substitute for the original documentation. Spend time with the linked resources throughout this page. Each methodology has depth that a single summary cannot fully capture, and understanding the original thinking will help you evaluate whatever CSS system a future team asks you to work in.

CUBE CSS

CUBE CSS, created by Andy Bell, stands for Composition, Utility, Block, Exception. Unlike methodologies that try to override or work around the cascade, CUBE embraces it. The philosophy is that global styles and the cascade should do most of the heavy lifting, and the four CUBE layers exist to handle the cases where you need more targeted control.

The Four Layers

Composition

Composition rules control the macro layout of a page. They define how elements flow and relate to each other spatially without caring what component sits inside them. Think of composition as the skeleton that holds everything in place:


        /* Composition: controls flow and spacing, not appearance */
        .flow > * + * {
            margin-top: var(--flow-space, 1em);
        }

        .grid-auto {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
            gap: var(--grid-gap, 1rem);
        }
    

Utility

Utilities are small, single-purpose classes that do exactly one thing. They represent deliberate, surgical overrides:


        .text-center { text-align: center; }
        .visually-hidden {
            clip: rect(0 0 0 0);
            clip-path: inset(50%);
            height: 1px;
            overflow: hidden;
            position: absolute;
            white-space: nowrap;
            width: 1px;
        }
    

Block

Blocks are the reusable UI components: cards, buttons, navigation bars. In CUBE, blocks are lightweight because the composition and global styles have already handled layout and common properties. A block only defines what is unique to that specific component:


        .card {
            background: var(--color-surface);
            border-radius: var(--radius-md);
            padding: var(--space-md);
        }
    

Exception

Exceptions handle deviations from a block's default appearance. Rather than creating modifier classes for every possible state, CUBE uses data attributes to signal exceptions:


        .card[data-variant="featured"] {
            border-left: 4px solid var(--color-accent);
        }

        .card[data-state="inactive"] {
            opacity: 0.6;
        }
    

Why CUBE Matters

The central insight of CUBE is that if your global styles are well designed, most elements already look correct before you write any component CSS. This reduces the total amount of CSS you ship and makes the cascade an ally rather than an obstacle. This philosophy aligns naturally with cascade layers, where a well ordered layer stack does the same kind of work.

ITCSS

ITCSS (Inverted Triangle CSS), created by Harry Roberts, is a file organization methodology. The core idea is to visualize your entire CSS project as an upside-down triangle. At the wide top, you have the most generic, far-reaching styles. As you move toward the narrow tip, styles become more specific, more explicit, and affect fewer elements.

The ITCSS Layers

The original ITCSS triangle defines seven layers, ordered from most generic to most specific:

  1. Settings – Design tokens and configuration values
  2. Tools – Originally for preprocessor mixins and functions. In native CSS, this layer often merges with Settings or disappears
  3. Generic – Resets, normalize stylesheets, and box-sizing rules
  4. Elements – Bare HTML element styles with no classes
  5. Objects – Layout patterns and structural containers
  6. Components – Styled UI components like cards, buttons, and forms
  7. Utilities – High-specificity helper classes

Translated into native CSS with cascade layers, the progression looks like this:


        @layer settings, generic, elements, objects, components, utilities;

        @layer settings {
            :root {
                --color-primary: oklch(0.55 0.2 260);
                --space-md: 1rem;
                --radius-md: 0.5rem;
            }
        }

        @layer generic {
            *, *::before, *::after {
                box-sizing: border-box;
            }
        }

        @layer elements {
            body {
                font-family: system-ui, sans-serif;
                line-height: 1.6;
            }
            a { color: var(--color-primary); }
        }

        @layer objects {
            .container {
                max-width: 70rem;
                margin-inline: auto;
                padding-inline: var(--space-md);
            }
        }

        @layer components {
            .card {
                background: var(--color-surface);
                border-radius: var(--radius-md);
                padding: var(--space-md);
            }
        }

        @layer utilities {
            .text-center { text-align: center; }
        }
    

A representative file tree for a native CSS project following ITCSS principles:


        [css]
        ├── components/
        │   ├── button.css
        │   └── card.css
        ├── elements/
        │   ├── headings.css
        │   └── links.css
        ├── generic/
        │   ├── box-sizing.css
        │   └── normalize.css
        ├── objects/
        │   ├── container.css
        │   └── grid.css
        ├── settings/
        │   ├── colors.css
        │   └── typography.css
        ├── utilities/
        │   └── helpers.css
        └── main.css
    

Key Principles

The power of ITCSS comes from three ordering principles that build on each other:

  • Generic to explicit – Start with the broadest rules and move toward narrowly targeted ones
  • Low specificity to high specificity – Element selectors before classes, classes before compound selectors, utilities last
  • Far reaching to localized – Rules that affect the entire page come first, rules that affect a single component come last

If you follow these principles, each new rule you write only adds to what came before it. You rarely need to undo or override earlier styles because the cascade is flowing in one direction. This is the same thinking behind cascade layer ordering: early layers are generic and later layers are specific.

SMACSS

SMACSS (Scalable and Modular Architecture for CSS), written by Jonathan Snook in 2011, divides CSS into five categories: Base, Layout, Module, State, and Theme. It was one of the first methodologies to formalize the idea that different kinds of CSS rules serve different purposes and should be organized accordingly.

The five SMACSS categories map loosely to ideas you have already seen:

  • Base – Default element styles (similar to ITCSS Generic + Elements)
  • Layout – Major page structure (similar to ITCSS Objects and CUBE Composition)
  • Module – Reusable UI components (similar to ITCSS Components and CUBE Block)
  • State – Rules that describe how a module looks in a particular state, often toggled by JavaScript
  • Theme – Optional layer for visual theming across the site

SMACSS introduced naming prefixes that are still widely recognized today:


        /* Layout prefix */
        .l-sidebar { width: 300px; }
        .l-content { flex: 1; }

        /* State prefix */
        .is-active { font-weight: bold; }
        .is-hidden { display: none; }
    

The SMACSS site notes that it was written in 2011 and remains as an archival and educational resource. Many of its ideas have been absorbed into newer methodologies, but understanding where those ideas came from helps you evaluate whatever system a team asks you to use.

BEM

BEM (Block, Element, Modifier) is a naming convention rather than a full architecture. It dictates how you name your CSS classes using a strict pattern:


        /* Block */
        .card { }

        /* Element: child of the block */
        .card__title { }
        .card__image { }

        /* Modifier: variation of the block or element */
        .card--featured { }
        .card__title--large { }
    

The double underscore separates a block from its element, and the double hyphen separates a block or element from its modifier. This naming pattern makes it immediately clear which component a class belongs to and what role it plays. In a modern CSS project with native nesting, you can achieve similar scoping without the naming overhead:


        /* Native CSS nesting achieves similar scoping */
        .card {
            background: var(--color-surface);
            border-radius: var(--radius-md);

            .title {
                font-size: var(--text-lg);
            }

            .image {
                border-radius: var(--radius-md) var(--radius-md) 0 0;
            }

            &.featured {
                border-left: 4px solid var(--color-accent);
            }
        }
    

BEM became extremely popular because it solves a real problem: in large projects with many developers, cryptic class names are ambiguous. BEM's strict naming removes that ambiguity. However, BEM also encourages a very flat, class-heavy approach to CSS that can work against the cascade rather than with it.

BEM in the Wild

You will encounter BEM on many teams and in many codebases. Understanding the naming pattern is important so you can read and contribute to those projects. However, this course does not use BEM as its coding standard. Instead, we rely on semantic class names, native CSS nesting, and cascade layers to achieve the same predictability without the naming overhead.

Comparing the Approaches

These four methodologies overlap more than they differ. The table below highlights what each one focuses on so you can see the relationships at a glance:

Methodology Primary Focus Key Idea
CUBE CSS Design philosophy Embrace the cascade; let global styles do most of the work
ITCSS File organization Order CSS by specificity, from generic to explicit
SMACSS Rule categorization Separate CSS into purpose-based categories
BEM Naming convention Block__element--modifier for unambiguous class names

Notice that CUBE and ITCSS are the most complementary. CUBE tells you how to think about your CSS (cascade first, components last), and ITCSS tells you how to organize your files (generic at the top, specific at the bottom). Combining them gives you both a mental model and a practical file structure.

This Course's Standard

This course adopts a modified CUBE philosophy with an ITCSS-aligned file structure, powered by native CSS features. Here is what that means in practice:

Layer Order

Every project in this course starts with a layer declaration that establishes the cascade order. The layer names map to a simplified version of the ITCSS triangle, adapted for native CSS:


        @layer tokens, base, layout, components, utilities;
    

Settings and Tools from ITCSS become tokens (custom properties). Generic and Elements merge into base (resets and element defaults). Objects become layout. Components and Utilities keep their names. This gives you the same specificity progression that ITCSS prescribes, enforced by the browser through cascade layers.

File Structure

Each layer maps to a directory. A main stylesheet declares the layer order and imports each file into its layer:


        [css]
        ├── base/
        │   ├── elements.css
        │   └── reset.css
        ├── components/
        │   ├── callout.css
        │   └── card.css
        ├── layout/
        │   └── primary.css
        ├── tokens/
        │   ├── colors.css
        │   └── variables.css
        ├── utilities/
        │   └── utilities.css
        └── main.css
    

This is the same pattern the course site itself uses. Open your browser DevTools on this page, inspect the stylesheet imports, and you will see a similar structure in action. Looking at how a real site organizes its layers is one of the best ways to internalize these ideas.

CUBE Influence

The CUBE philosophy shapes how code is written within each layer:

  • Tokens and base styles do most of the work. Colors, spacing, typography, and element defaults are defined globally so that most elements look correct before any component CSS is written.
  • Layout classes handle composition. Grid areas, content widths, and spacing rhythm live in the layout layer, separate from any component.
  • Component classes are lightweight. Because tokens and base styles handle so much, component files only define what is unique to that specific component.
  • Utilities are intentional overrides. Small helper classes like .visually-hidden or .text-center live in the last named layer so they win by layer order without needing !important.

What We Do Not Use

This course does not use BEM naming. Instead, we use semantic, descriptive class names and rely on native CSS nesting and cascade layers for scoping and specificity control. We also do not use preprocessors like Sass for new projects. Modern CSS provides custom properties, nesting, and @layer natively, making preprocessors unnecessary for the patterns we teach.

Color and Theming

You may be wondering how colors fit into the token layer. Authoring design tokens with oklch(), color-mix(), and light-dark() is covered in Unit 3. For now, know that the token layer is where color values live, and you will learn how to write them using modern color functions later in the course.

Looking Ahead

Understanding these philosophies gives you a framework for evaluating any CSS system you encounter, whether it is a team's existing BEM codebase, a Tailwind utility-first project, or something entirely custom. The principles are consistent even when the names change: order your CSS from generic to specific, let the cascade work for you, and keep each file focused on a single concern.

In the CSS Architecture hands-on reading, you will apply this course's standard to your own portfolio by setting up a layered file structure, writing token files, and importing everything into a main stylesheet with @layer.

Resources

The following references were used throughout this reading. Each links to the original source or the most authoritative available documentation.