Choose a CSS property by the layout or presentation contract it must preserve. The pages below use small component examples and state what each declaration costs to maintain or render.
Boxes and dimensions
Size components without clipping their content.
- CSS box-sizing: include padding and borders in a declared size
- CSS margin collapse: explain vertical gaps before changing them
- CSS margin and padding shorthands: know which edge a value reaches
- CSS min and max sizes: let content grow without breaking the layout
- CSS border, radius, and outline: separate box edges from focus indication
- CSS display and visibility: choose the intended hidden state
- CSS aspect-ratio: reserve a stable box without fixing both dimensions
Placement and flow
Place repeated content while preserving its source sequence.
- CSS grid template areas: name regions without rewriting document order
- CSS grid auto-placement: let repeated records fill available tracks
- CSS flex shorthand and order: distribute space without changing meaning
- CSS float and flow-root: contain legacy text wraps
Type and controls
Keep text, links, and native controls readable.
- CSS link decoration and states: preserve a visible navigation cue
- CSS font shorthand and fallback stack: keep type stable during loading
- CSS line height and measure: protect long-form reading
- CSS form appearance and accent color: retain native behavior
Paint and fallbacks
Use effects without carrying required meaning in decoration.
- CSS background size and position: crop decoration deliberately
- CSS invalid declarations and fallbacks: fail locally, not silently
- CSS filter effects: use image treatment without obscuring evidence
Connected paths
Common Mistakes
- Do not pick a property by name before inspecting the containing layout.
- Do not use paint effects to replace labels, values, or interaction state.
Containment boundaries
Interaction and flow boundaries
- CSS isolation: give a component a stacking boundary
- CSS pointer-events: remove decorative hit targets carefully
- CSS scroll offsets: reveal anchors below a persistent header
- CSS break-inside: keep small report units together in print
Selection and text axes
- CSS user-select: keep copyable data copyable
- CSS hyphens: wrap prose with a declared language
- CSS writing-mode: test layout axes rather than rotating text
- CSS cursor: match the pointer cue to a real action
Resets and visual effects
- CSS all and revert-layer: reset with a named boundary
- CSS clip-path: clip decoration without hiding required content
- CSS backdrop-filter: preserve contrast beneath translucent panels
Rendering and input
- CSS scrollbar-gutter: reserve space when a panel starts scrolling
- CSS touch-action: scope gesture control to the interactive surface
- CSS will-change: reserve a rendering hint for measured trouble
- CSS transform-origin: move a visual pivot without moving the layout box
- CSS mix-blend-mode: confine decorative blending to one surface
- CSS mask-image: fade decoration without fading data
- CSS shape-outside: let prose wrap around a floated decoration
- CSS color-mix: derive a surface without assuming contrast
- CSS light-dark: bind component colors to the active scheme
- CSS font-variant-numeric: keep changing values aligned
- CSS @page: set a print sheet contract without hiding overflow
- CSS scroll-behavior: make smooth jumps optional
Forms, type, and contrast
- CSS field-sizing: let a note grow within firm limits
- CSS caret-color: keep the insertion point visible
- CSS placeholder-shown: style empty state without replacing a label
- CSS user-invalid: delay visual errors until interaction warrants them
- CSS autofill state: retain contrast when the browser fills a control
- CSS font-size-adjust: steady readable fallback text
- CSS font-display: choose what readers see while a font loads
- CSS text-wrap balance: improve short headings without truncation
- CSS tab-size: render source indentation without rewriting code
- CSS scrollbar-width: keep scrolling discoverable
- CSS forced-color-adjust: preserve a color only for a narrow reason
- CSS prefers-contrast: strengthen an already readable interface
Modern layout and motion
- CSS container query units: size type to its component
- CSS container style queries: branch on a local token
- CSS @starting-style: define an element's entry state
- CSS discrete transitions: keep a closing panel visible long enough to fade
- CSS interpolate-size: animate toward content height carefully
- CSS anchor positioning: place a hint beside its control
- CSS view timelines: tie optional motion to visible progress
Type, color, and assets
- CSS variable fonts: declare the supported weight range
- CSS font-optical-sizing: inspect the font's size-specific drawings
- CSS font-synthesis-weight: prevent a counterfeit bold face
- CSS @counter-style: give a finite marker set an honest fallback
- CSS image-set: offer resolution choices for decoration
- CSS color-gamut: add a wide-color accent behind an sRGB base
- CSS oklch: tune a surface color without guessing contrast
- CSS background-clip text: keep a decorative headline readable
Scroll and state contracts
- CSS overflow-anchor: exclude a volatile child, not the whole feed
- CSS display contents: remove a layout box with care
- CSS scroll-snap-stop: require a stop only for short, uniform cards
- CSS :focus-within: mark the active field group
- CSS :target: confirm the section reached by a fragment
- CSS object-position: move a thumbnail crop without changing the evidence
- CSS scrollbar-color: keep the scroll affordance visible
- CSS text-decoration-skip-ink: keep underlined copy legible
Type, fragments, and top-layer surfaces
- CSS unicode-range: request only the font subset a page uses
- CSS font-variant-ligatures: keep identifiers visually literal
- CSS :lang(): style text from its declared language
- CSS text-transform: change display case without corrupting source data
- CSS box-decoration-break: control a highlight across wrapped lines
- CSS ::backdrop: dim a modal without faking modality
- CSS :popover-open: style only the visible popover state
- CSS background-attachment local: move decoration with scrolled content
Native controls and cue paint
- CSS ::file-selector-button: style the picker without replacing it
- CSS :read-only: distinguish fixed values from disabled controls
- CSS :indeterminate: show a mixed selection without inventing its meaning
- CSS :default: mark the form's default action, not the last clicked button
- CSS :required and :optional: reinforce a real form requirement
- CSS ::placeholder: keep example text readable and disposable
- CSS :nth-child(of selector): count only the rows that match
- CSS ::cue: improve caption contrast without editing the transcript
Direction, glyphs, and media paint
- CSS :dir(): respond to computed text direction
- CSS text-orientation: choose glyph posture in vertical text
- CSS text-emphasis: add a typographic cue without hiding meaning
- CSS image-rendering: preserve a pixel map's hard edges
- CSS font-variation-settings: use a verified custom axis
- CSS background-blend-mode: keep the layer order explicit
- CSS :fullscreen: lay out media after the browser enters full screen
- CSS widows and orphans: keep short print paragraphs together
Rendering contracts and output choices
- CSS auto-fit vs auto-fill: decide what empty grid tracks should do
- CSS overflow: clip vs hidden: avoid an accidental scroll container
- CSS :open: style the native open state without inventing one
- CSS :user-valid: confirm a checked field without premature praise
- CSS prefers-reduced-transparency: keep overlays readable by default
- CSS animation-composition: preserve a base transform during an effect
- CSS print-color-adjust: request fidelity without trusting printer color
- CSS text-wrap: pretty: spend line-breaking work where copy merits it
Component boundaries and transition identity
- CSS :host: make a component variant an explicit host contract
- CSS ::part(): expose a narrow styling surface across Shadow DOM
- CSS ::slotted(): style only the assigned element
- CSS ::highlight(): paint searched text without changing its markup
- CSS view-transition-name: give one live element one transition identity
- CSS view-transition snapshots: animate presentation, then restore interaction
- CSS @supports selector(): gate a relational selector safely
- CSS baseline alignment: line up mixed text by its reading edge
Native states and navigation surfaces
- CSS :defined: preserve content while a custom element upgrades
- CSS :state(): expose one internal custom-element state to styling
- CSS ::details-content: style the disclosure body while keeping native behavior
- CSS ::target-text: preserve the reader's place after a text-fragment link
- CSS @view-transition: opt in only the pages that can tolerate a cross-page animation
- CSS scripting media feature: reveal a fallback when scripts cannot run
- CSS :modal: style the active modal state without faking modality
- CSS :picture-in-picture: reflect detached video state without losing the page transcript
