---
title: "HTML and CSS playbook · Agent Wranglers"
url: https://agentwranglers.se/playbook/html-css
updated: 2026-10-21
licence: "All rights reserved"
---

# HTML and CSS playbook

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

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.

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.

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/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.

## Chapters

1. [Structure and files](https://agentwranglers.se/playbook/html-css/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. (4 required, 1 recommended)
2. [The cascade](https://agentwranglers.se/playbook/html-css/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. (6 required, 1 avoid)
3. [Naming and state](https://agentwranglers.se/playbook/html-css/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. (4 required, 2 recommended)
4. [HTML structure and reuse](https://agentwranglers.se/playbook/html-css/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. (4 required, 3 recommended)
5. [Checks in code](https://agentwranglers.se/playbook/html-css/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. (5 required, 2 recommended)

See all 32 rules on one page in the [checklist](https://agentwranglers.se/playbook/html-css/checklist).

## Related playbooks

- [Site architecture](https://agentwranglers.se/playbook/website/site-architecture) in the Website playbook. Build every repeated piece of HTML from one module, with class names that module owns.
- [Styles and components](https://agentwranglers.se/playbook/app-ui/styles-and-components) in the App interface playbook. Take every style value from design tokens and build each control once, with variants.
- [End-to-end and browser tests](https://agentwranglers.se/playbook/testing/end-to-end-and-browser-tests) in the Testing playbook. Prove in a browser that pages still render and work after a change to shared CSS.
- [Rules as code](https://agentwranglers.se/playbook/engineering/rules-as-code) in the Engineering playbook. Turn each CSS and HTML rule into a check that fails the build, not a review comment.
