coderef

CSS Quick Reference

CSS selectors, the box model, flexbox, grid, typography, colors, responsive design, variables and animation.

6 sections · 45 snippets · updated Oct 14, 2026

Click any snippet to copy it.

Selectors

Choosing elements to style.

  • Element / class / id
  • Descendant / direct child
  • Group selectors
  • Attribute
  • States
  • Position in parent
  • Not / has
  • Before / after content

Box model & spacing

Size, padding, borders and margins.

  • Include padding in width
  • Padding / margin
  • Width limits
  • Border
  • Shadow
  • Hide overflow / scroll
  • Aspect ratio

Layout

Flexbox, grid and positioning.

  • Row with space between
  • Center anything
  • Wrap items
  • Item fills remaining space
  • Responsive card grid
  • Span grid columns
  • Position over a parent
  • Sticky header
  • Stack order

Typography & color

Text and colors.

  • Font
  • Line height / letter spacing
  • Align / transform
  • Truncate with …
  • Balanced headings
  • Colors
  • Gradient
  • Load a web font

Responsive

Adapting to screen size.

  • Media query
  • Dark mode
  • Reduced motion
  • Fluid size
  • Container query
  • Responsive image

Variables & effects

Custom properties, transitions and animation.

  • Define and use a variable
  • Variable with fallback
  • Transition
  • Transform
  • Keyframe animation
  • Visually hidden (screen-reader only)
  • Nesting

← All quick references