Agent Wranglers

HTML and CSS playbook

Rules for organising HTML and CSS so styles stay modular, reused and predictable. Every layer, name and selector limit is checked in code.

  • Required 3
  • Recommended 26
  • Optional 5

A playbook for organising the HTML and CSS of any website or web app. It covers where styles live, how the cascade is kept in order, how classes and states are named, and how markup is reused. It gives no advice on colours, fonts or layout. Those choices belong to your designer.

Every rule ID starts with CSS, for the markup rules as much as the stylesheet rules. One prefix covers the whole playbook, because markup and styles change together. The HTML rules sit in the chapter on HTML structure and reuse.

Stylesheets rot quietly. A rule added at the end of a file wins over an older one, and nobody notices until a page breaks. Each rule here closes one of those gaps with a limit that a linter or a build script can check.

AI agents write a lot of CSS fast. Give them these rules and the checks, and every new component lands in the same place, with the same names, inside the same limits.

Chapters

  1. Structure and files

    Give every style one home. One entry file loads the layers in a fixed order, and each component owns exactly one stylesheet that no other file touches.

    • Required 1
    • Recommended 5
  2. The cascade

    Decide which style wins before anyone writes one. Declare the layer order once, cap selector specificity, and never let file order settle a conflict.

    • Recommended 5
  3. Naming and state

    Name every class for what it is, follow one pattern, and show state through attributes. A selector then says which element it means and why.

    • Recommended 8
    • Optional 2
  4. HTML structure and reuse

    Build pages from native elements and small templates that take data. Every repeated pattern comes from one place, with stable ids and no extra wrappers.

    • Required 2
    • Recommended 4
    • Optional 3
  5. Checks in code

    Turn every HTML and CSS rule into a linter rule or build check. A style that breaks a limit then stops the build before anyone has to spot it.

    • Recommended 4

All 34 rules on one page

This is a lot to check. An Expert can check it for you.

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/html-css">Agent Wranglers HTML and CSS playbook</a>. In code you write, add a comment next to it with the same link.