Apply

CSS architecture decision trees

Use these when CSS arguments start, code reviews lose clarity, or someone reaches for !important before asking where the code belongs.

Ask this first

Stop adding specificity first.

Ask: Am I changing behaviour, presentation, structure, or temporary state? That answer decides the destination before writing CSS.

Most bad CSS starts with the wrong destination, not the wrong selector. Decide ownership first.

Utility or component?

  1. Does this solve a universal accessibility problem?

    YesUtility

    NoNext question

  2. Does this same pattern repeat together often?

    YesComponent

    NoNext question

  3. Is it only a small one-off visual adjustment?

    YesTheme

    No

    If you need to explain it twice, it probably needs a component

Modifier or state?

  1. Is this a permanent reusable variation?

    YesModifier

    NoNext question

  2. Is this temporary, conditional, or JS-driven?

    YesState class

    No

    If it disappears when the user leaves, it is probably state

Base vs theme vs component

  1. Should this apply globally across the whole site?

    YesBase

    NoNext question

  2. Is this only visual presentation?

    YesTheme

    NoNext question

  3. Is this specific to one UI pattern?

    YesComponent

    No

    You are probably writing a hack

Hack or real fix?

  1. Is this urgent and temporary?

    YesHacks layer

    NoNext question

  2. Will this still exist in 6 months?

    YesReal fix

    No

    If it feels permanent, stop calling it temporary

Layout problem or component problem?

  1. Is the issue about page structure and positioning?

    YesLayout

    NoNext question

  2. Is it specific to one reusable UI pattern?

    YesComponent

    No

    If three components share it, it is probably layout

@scope, BEM, or neither?

  1. Do you need native selector boundaries?

    Yes@scope

    NoNext question

  2. Do you need explicit naming for legacy teams?

    YesBEM may help

    No

    Use semantic ownership and shallow selectors

Next useful pages