CSS Reference
A reference of CSS properties for page layout: syntax, values, initial value and live examples you can open in the editor.
Layout
display
The CSS display property sets how an element takes part in layout: as a block, inline with text, as a flex or grid container, or not at all. Values, examples.
position
The CSS position property: how static, relative, absolute, fixed and sticky work, what top and left are measured from and why sticky stops working.
justify-content
CSS justify-content distributes space between items along the main axis in flexbox and grid: flex-start, center, space-between, space-evenly.
Grid
CSS Grid lays out rows and columns: display: grid, grid-template-columns, fr, repeat() and minmax(), and a responsive grid without media queries.
flex
The CSS flex property is a shorthand for flex-grow, flex-shrink and flex-basis: what flex: 1, flex: auto and flex: none mean and how items share space.
gap
The CSS gap property sets the space between items of a flex or grid container without extra margins: one or two values, row-gap and column-gap.
grid-template-columns
The CSS grid-template-columns property defines the columns of a grid: px, %, fr, repeat(), minmax() and auto-fill/auto-fit for a responsive grid.
align-items
The CSS align-items property aligns the items of a flex or grid container along the cross axis: stretch, center, flex-start, flex-end and baseline.
Box model
margin
The CSS margin property sets an element's outer spacing: the 1–4 value forms, margin: auto for centering, negative margins and how vertical margins collapse.
padding
The CSS padding property sets the inner space between the border and the content: the 1–4 value forms, percentages, its effect on width and box-sizing.
Text and fonts
Colors and backgrounds
Concepts
@media
CSS media queries (@media) apply styles depending on screen width, orientation and user settings: min-width, max-width, mobile-first and common mistakes.
CSS selectors
CSS selectors pick elements to style: by tag, class, id, attribute and state, plus combinators and specificity — with examples for beginners.
:nth-child()
The CSS :nth-child() pseudo-class selects elements by position among siblings: odd and even, 3n, 3n+1, -n+3 for the first three, and :nth-of-type.