CSS Reference ยท Multi-column and Fragmentation
The column-span property
Reference for the CSS column-span property: let a heading or banner stretch across every column of a multi-column container, with live examples and usage notes.
The column-span property lets an element inside a multi-column container break out of the columns and stretch across the full width of the container. It is the tool for a heading, a pull quote or a divider that sits in the middle of an article while the text above and below it stays in columns.
When a spanning element appears, the browser ends the current set of columns, places the element across the whole width, and starts a fresh set of columns below it. The content before and after the element is balanced separately.
.article { column-count: 3; } .article h2 { column-span: all; }
Try it
Change column-span: all to none in the editor and the heading shrinks back into a single column.
Syntax
column-span: none | all;
- Initial value:
none - Applies to: in-flow block-level elements
- Inherited: no
- Animatable: no (discrete)
- Computed value: as specified
Values
| Value | Description |
|---|---|
none |
The element stays inside a single column. This is the default. |
all |
The element spans every column of the nearest multi-column container and splits the columns above and below it. |
Usage notes
- Only direct descendants count. The element must be a descendant of the multi-column container whose columns it should span, and it spans the columns of the nearest multi-column ancestor. If a heading is nested in a flex or grid item, the span applies inside that item's own context, which is rarely what you want.
- There is no "span 2" value. The common values are
noneandall. If you need a block that crosses only some of the columns, use grid instead of columns. - The container needs columns. Without
column-countorcolumn-widthon an ancestor,column-spanhas no visible effect. - Balance changes. Because each stretch of columns is balanced on its own, adding a spanning heading can change how tall each group is. That is expected.
- Margins. Margins of the spanning element do not collapse with the surrounding column content. Add vertical margin to the spanning element itself to separate it from the text.
- Accessibility. The reading order stays the same as the source order, so a spanning heading is read exactly where it appears in the HTML. That makes it safe for headings.
Browser support
Supported in all current major browsers for the none and all values; check a compatibility table before relying on unusual combinations, such as spanning elements inside nested containers.
Related
columnsโ shorthand for column width and countcolumn-countโ the number of columnscolumn-ruleโ the line between columnsbreak-insideโ keep a box in one column- Lesson: Multi-column Layout