div

Generic block-level container. In Vanilla Breeze, div usage is discouraged — prefer semantic elements and VB layout primitives.

Philosophy

Vanilla Breeze takes an intentional stance: <div> is a last resort, not a default. The VB conformance checker flags every <div> as a warning, and the semantic check raises it as an error for new code.

This is not about being pedantic — semantic elements provide:

  • Accessibility: Screen readers can navigate by landmarks (<nav>, <main>, <aside>)
  • SEO: Search engines understand content structure from semantic markup
  • Readability: Code is self-documenting when elements describe their purpose
  • Less CSS: VB styles semantic elements directly — no class soup

Semantic Alternatives

For every common <div> pattern, a semantic element exists:

Instead ofUse
<div class="card"><article>
<div class="sidebar"><aside>
<div class="nav"><nav>
<div class="header"><header>
<div class="footer"><footer>
<div class="main"><main>
<div class="section"><section>
<div class="actions"><footer> or <menu>
<div class="group"><fieldset>
<div data-layout="stack">Put data-layout on the semantic parent

Layout Without Divs

VB's layout attributes (data-layout) and custom elements (<layout-stack>, <layout-grid>, etc.) can be applied directly to semantic elements:

When no semantic element fits, VB layout custom elements (<layout-stack>, <layout-grid>, <layout-cluster>) serve as the container — they are more descriptive than <div> because they declare layout intent.

Legitimate Uses

There are a few cases where <div> is the correct choice:

  • <dl> grouping: HTML5 allows <div> inside <dl> to group <dt>/<dd> pairs (for striped styling)
  • Form field groups: Wrapping radio/checkbox groups inside <form-field>
  • Third-party widgets: When external libraries require a container div
  • CSS Grid/Flex children: When you genuinely need a non-semantic grid cell

Conformance Enforcement

VB enforces semantic HTML through automated tooling:

  • vb/no-div — Flags any <div> element. Suggests semantic alternatives.
  • vb/no-div-wrapper — Flags <div> wrapping a single semantic child (the div is unnecessary).
  • Allowlist: Known legitimate uses can be added to .claude/vb-conformance-allowlist.json

Run npm run conformance to check your HTML files.

The VB Refinement Checklist

When auditing existing code with divs, follow this order:

  1. Div audit: Can each div be replaced with a semantic element?
  2. Wrapper audit: Is a div wrapping a single child that could receive the attributes directly?
  3. data-layout audit: Is data-layout on a div when it could be on the semantic parent?
  4. Class audit: Are VB element-scoped classes available (e.g., form.stacked)?
  5. Semantic opportunities: Can <footer> replace a button group div? Can <header> replace a title wrapper?

Accessibility

  • <div> has no implicit ARIA role — it is invisible to screen readers
  • Screen readers cannot navigate by divs; they can navigate by landmarks, headings, lists, and other semantic elements
  • Every div you replace with a semantic element improves the accessibility tree

Related

  • <span> — Generic inline container (same philosophy: last resort)
  • <section> — Thematic grouping of content
  • <article> — Self-contained content
  • <aside> — Tangentially related content
  • <nav> — Navigation sections
  • <header> — Introductory content
  • <footer> — Footer content and action groups
  • <main> — Dominant content of the page
  • <menu> — Action button groups
  • <fieldset> — Form field grouping