How 'naming' expresses structure,
intent, and clarity
—Part of CSS Primer for the AI Era — Structure
Components are easier to understand when
their 'internal structure' is expressed clearly.
This also makes it easier for AI to work with them.
One of the simplest ways to think about structure
is the
Block / Element / Modifier
'mental model'.
'BEM' is not a rule
or a methodology to memorize.
It is, rather, a way of thinking about
components as 'shapes'
with parts and variations.
The BEM visual mental model:
A 'block' is a thing.
An 'element' is a part of the thing.
A 'modifier' is a variation of the thing.
This model gives humans and AI
a 'shared language' for describing structure.
A 'block' is a standalone component —
a meaningful piece of UI that can exist on its own.
Examples:
A block:
A block is the root of a component.
A quiet principle:
If it can stand alone,
it is a block.
An element is a part of a block —
something that only
makes sense inside that block.
Examples inside a card block:
card_headercard_bodycard_footercard_imageExamples inside a nav block:
nav_listnav_itemnav_linkSome characteristics of Elements:
A simple rule:
If it is part of the block’s internal structure,
it is an element.
A modifier expresses a variation —
a change in appearance, tone, or behavior.
Examples:
button–primarybutton–smallcard–highlightednav_item–activeModifiers:
A simple truth:
Modifiers express difference without
breaking the component.
This model gives us (and AI):
It also helps AI understand:
AI does not infer structure.
It needs humans to express it.
A quiet reminder:
AI can style a component beautifully
but only when
the structure is clear.
Let’s take a simple example: a card.
Block
<div class="card">
Elements
<div class="card__header">...</div> <div class="card__body">...</div> <div class="card__footer">...</div> </div>
Modifier
<div class="card card--highlighted">
This structure tells AI:
It also makes CSS simpler, clearer, and more maintainable.
This is not about strict naming conventions.
It is about thinking in components.
We can adapt the naming:
card-header instead of card_headeris-active instead of nav_item–activevariant=“primary” in a frameworkdata-state=“open” for behaviorThe model remains the same:
A simple truth:
The names can change.
The thinking stays the same.
AI does not “see” the whole codebase.
It only sees what we show it.
Clear structure helps AI:
Humans provide the shape.
AI fills in the details.
A quiet reminder:
Structure is guided by human judgment.
Style becomes collaborative
once the structure is understood.
*Suggested Next Reading: Naming and Shape: How Structure Supports Style
Tony de Araujo —New York | Lisbon