Reference

HTML, CSS & browser APIs

Look up semantic HTML, forms, CSS layout, events, DOM operations and common browser APIs.

Scope and conventions

Modern browser platform examples, independent of a framework. HTML/CSS excerpts belong in the appropriate document/style context; DOM snippets assume a browser and named elements/data; TypeScript annotations clarify DOM types and need compilation or removal in plain JavaScript. Check target-browser support for newer features.

Selectors & cascade

Read common selectors

Web platform

A space selects descendants; > selects direct children; + selects an adjacent following sibling. Classes and attributes express different matching conditions.

Fragment

Web platform · Read common selectors
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
.card .title { font-weight: 600; }
.card > button { margin-block-start: 1rem; }
input + .hint { color: gray; }
button[disabled] { opacity: .6; }

Resolve cascade before comparing specificity

Web platform

Origin, importance and cascade layers are considered before selector specificity. Specificity compares ID, class/attribute/pseudo-class, then type/pseudo-element components. Equal-priority ties can use source order.

Fragment

Web platform · Resolve cascade before comparing specificity
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
#panel .item { color: green; } /* 1-1-0 */
.item.active { color: blue; } /* 0-2-0 */

Inline declarations and !important have their own cascade positions. Specificity is not a single universal numeric weight.

Use :where, :is and :has with their specificity rules

Web platform

:where contributes zero specificity. :is and :has take specificity from their argument selector list under their defined rules. :has selects a relative relationship, not only ancestors in a fixed DOM direction.

Fragment

Web platform · Use :where, :is and :has with their specificity rules
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
:where(.card, #panel) { padding: 1rem; }
.card:has(> input:checked) { border-color: green; }

Check browser support and avoid unnecessarily expensive broad relational matching.

Share values through custom properties

Web platform

Custom properties participate in cascade/inheritance and are substituted with var(). The fallback applies to an absent/invalid custom property, not every final property-value error.

Fragment

Web platform · Share values through custom properties
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
:root { --gap: 1rem; }
.stack { gap: var(--gap, 1rem); }

Preserve focus visibility and motion preferences

Web platform

Visible focus identifies the active keyboard target. Respect reduced-motion preferences when animation is not necessary to convey state.

Fragment

Web platform · Preserve focus visibility and motion preferences
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
  .animated { animation: none; transition: none; }
}

Keep a useful focus indicator across themes. Reduced motion should preserve access to the resulting state.