Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Grid

The grid-column property

Reference for the CSS grid-column shorthand: place a grid item across columns with line numbers, span, negative lines and names, with live examples.

The grid-column property says which columns a grid item occupies. It is a shorthand for grid-column-start and grid-column-end, separated by a slash. Lines are numbered from 1 at the start edge of the explicit grid, so a grid with three columns has four lines.

CSS
.wide  { grid-column: 1 / 3; }      /* from line 1 up to line 3: two columns */
.span  { grid-column: span 2; }     /* two columns, starting where auto-placement puts it */
.full  { grid-column: 1 / -1; }     /* all explicit columns */

Try it

Line numbers, span and -1

Each item either names its lines or lets auto-placement find a slot. 1 / -1 always reaches the last explicit line, so it makes a full-width row.

Syntax

CSS
grid-column: <grid-line> [ / <grid-line> ]?;
/* grid-line: auto | <custom-ident> | [ <integer> && <custom-ident>? ] | [ span && [ <integer> || <custom-ident> ] ] */
  • Initial value: auto
  • Applies to: grid items and absolutely positioned boxes whose containing block is a grid area
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
auto No preference: auto-placement chooses, spanning one column by default.
<integer> A line number. Positive numbers count from the start, negative numbers from the end (-1 is the last explicit line).
span <n> Spans n columns from the opposite line.
<name> A named line. A line name 2 means the second line with that name.
<start> / <end> Two values separated by a slash. If only a start is given, the end is auto.

Usage notes

  • Lines, not columns. grid-column: 2 / 3 is the second column. The end value is the line after the item, which is why 1 / 3 is two columns wide.
  • Reversed lines. If start is after end, the browser swaps them. If both are the same line, the end becomes span 1.
  • Negative numbers only count explicit lines. -1 points to the end of the explicit grid; items placed in implicit columns are beyond it.
  • Implicit columns. Using a line number beyond the defined tracks creates implicit columns, sized by grid-auto-columns.
  • A single name. A custom identifier like grid-column: content uses the lines content-start and content-end, if they exist (for example from an area of that name).
  • Mind the order. A span item can move where auto-placement puts later items, so mixing it with explicit placements can leave holes; see grid-auto-flow.

Browser support

Supported in all current browsers.