CSS column-span Property
The column-span property controls whether an element extends across all columns in a CSS multi-column layout instead of remaining within an individual column.
It is commonly used for headings, section titles, and other content that should occupy the full width of a multi-column container. An element with column-span: all is called a spanning element, or spanner.
The property accepts two values: none and all. Unlike CSS Grid, multi-column layout does not provide a standard way to span an exact number of columns, such as two out of three.
column-span Syntax
The column-span property accepts either none or all.
selector {
column-span: all;
}
General Syntax
selector {
column-span: none | all;
}
Default Behavior
.section-heading {
column-span: none;
}
Span All Columns
.section-heading {
column-span: all;
}
CSS-Wide Keywords
.section-heading {
column-span: inherit;
}
.section-heading {
column-span: initial;
}
.section-heading {
column-span: unset;
}
.section-heading {
column-span: revert;
}
.section-heading {
column-span: revert-layer;
}
Invalid Numeric Value
.section-heading {
column-span: 2;
}
The value 2 is invalid. The property does not accept a number specifying how many columns an element should span.
Property Values
The column-span property has two standard values.
| Value | Description |
|---|---|
none |
The element does not span across columns and remains in the normal multi-column flow. This is the initial value. |
all |
The element spans across all columns, separating the content into multi-column sections before and after it. |
CSS-Wide Keywords
| Value | Description |
|---|---|
inherit |
Uses the computed value from the parent element. |
initial |
Resets the property to none. |
unset |
Resets the property to none because it is not inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | none |
| Inherited | No |
| Applies to | In-flow block-level elements, with exclusions for certain formatting contexts |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
| Layout effect | Changes column fragmentation and the placement of spanning content |
Unlike decorative column properties, column-span changes how the browser divides and arranges content within the multi-column container.
How It Works
When an eligible element has column-span: all, the browser places it across the full multi-column container and creates separate multi-column sections around it.
Step 1: Create a Multi-column Container
.article {
column-count: 3;
column-gap: 30px;
}
Step 2: Add a Heading Within the Content
<div class="article">
<p>First paragraph of content.</p>
<p>Second paragraph of content.</p>
<h2>Section Heading</h2>
<p>Third paragraph of content.</p>
<p>Fourth paragraph of content.</p>
</div>
Step 3: Make the Heading Span All Columns
.article h2 {
column-span: all;
}
Step 4: Divide the Content Into Sections
The browser lays out the paragraphs before the heading in one multi-column section. The heading then occupies the full container width, and the remaining paragraphs form another multi-column section below it.
Step 5: Continue the Column Flow
Content after the spanning heading resumes in columns using the container's existing column settings.
Important Distinction
The heading does not become a separate column. It interrupts the column flow and spans the available width across all columns.
none
The none value keeps an element in the normal multi-column flow.
Basic Example
.article h2 {
column-span: none;
}
Default Behavior
.article {
column-count: 3;
}
.article h2 {
column-span: none;
}
The heading is laid out within the column flow rather than extending across the full container.
Normal Column Flow
<div class="article">
<p>Introduction to HTML elements.</p>
<h2>HTML Attributes</h2>
<p>Attributes provide additional information about elements.</p>
</div>
With column-span: none, the heading remains part of the content flowing through the columns.
Overriding a Spanning Rule
.article h2 {
column-span: all;
}
.article h2.normal-heading {
column-span: none;
}
The more specific rule restores normal column flow for headings with the normal-heading class.
When to Use
Use none when headings and other elements should remain inside the column flow instead of interrupting it.
all
The all value makes an eligible element span the entire multi-column container.
Basic Example
.article h2 {
column-span: all;
}
Spanning a Section Heading
.article {
column-count: 3;
column-gap: 30px;
}
.article h2 {
column-span: all;
}
Spanning a Notice
.article .notice {
column-span: all;
padding: 15px;
background-color: #eef5ff;
border: 1px solid #99bbdd;
}
Spanning an Image Container
.article figure {
column-span: all;
margin: 20px 0;
}
.article figure img {
display: block;
max-width: 100%;
height: auto;
}
Column Flow Before and After
Content before the spanner is arranged in columns above it. Content after the spanner continues in a new multi-column section below it.
Width Behavior
The spanning element participates in layout across the container's available width rather than being restricted to one column.
When to Use
Use all for section headings, full-width notices, illustrations, and other content that should visually separate groups of columns.
Spanning Headings
Headings are among the most common uses of column-span: all.
Full-Width Article Heading
.article {
column-count: 3;
column-gap: 30px;
}
.article h1 {
column-span: all;
}
Section Heading
.article h2 {
column-span: all;
margin: 20px 0 10px;
}
Selective Spanning
.article .full-width-heading {
column-span: all;
}
Example HTML
<article class="article">
<h1 class="full-width-heading">Understanding CSS Layout</h1>
<p>CSS provides several ways to arrange content on a page.</p>
<p>Multi-column layout divides flowing content into columns.</p>
<h2 class="full-width-heading">Working with Columns</h2>
<p>The column-count property sets the preferred number of columns.</p>
<p>The column-gap property controls the spacing between columns.</p>
</article>
Heading Hierarchy
The column-span property changes visual layout, not heading semantics. Use heading levels according to the document structure rather than the desired column arrangement.
Spacing Around Headings
Use margins and padding to create appropriate separation between a spanning heading and the columns above or below it.
Multiple Spanning Elements
A multi-column container can contain multiple spanning elements.
Example HTML
<div class="article">
<h2>HTML Basics</h2>
<p>HTML elements define the structure of a document.</p>
<p>Attributes provide additional information about elements.</p>
<h2>CSS Basics</h2>
<p>CSS selectors identify the elements to style.</p>
<p>CSS declarations define the styles applied to those elements.</p>
<h2>Responsive Design</h2>
<p>Media queries allow styles to adapt to different conditions.</p>
<p>Flexible layouts help content fit different screen sizes.</p>
</div>
Example CSS
.article {
column-count: 2;
column-gap: 30px;
}
.article h2 {
column-span: all;
margin: 20px 0 10px;
}
How Multiple Spanners Work
Each spanning heading interrupts the column flow. The browser creates a new multi-column section for the content following that heading.
Section Independence
Each group of columns between spanning elements is laid out separately. The columns in one section do not continue through a spanning element into the next section.
Practical Consideration
Too many spanning elements can produce short column sections and unnecessary visual interruptions. Use them when full-width separation improves readability.
Column Balancing
Spanning elements affect how content is distributed between columns.
Default Balancing
.article {
column-count: 3;
column-fill: balance;
}
The balance value asks the browser to distribute content across columns as evenly as possible, subject to layout constraints.
Adding a Spanner
.article {
column-count: 3;
column-fill: balance;
}
.article h2 {
column-span: all;
}
The spanning heading divides the content into separate multi-column sections. The browser balances the columns in each section according to the applicable layout rules.
Short Sections
When a section contains little content, its columns may be relatively short because the browser balances that section independently.
Fixed-Height Containers
.article {
height: 350px;
column-count: 3;
column-fill: auto;
}
The auto value generally fills columns sequentially when the container has a definite height. However, content separated by spanning elements is subject to the multi-column specification's balancing rules for those sections.
Important Distinction
The column-span property does not directly set column heights. It creates layout boundaries that can affect how column heights are calculated.
Fragmentation and Content Flow
Multi-column layout distributes content into column fragments. A spanning element interrupts that fragmentation.
Content Before the Spanner
The browser lays out preceding content in columns until it reaches the spanning element.
The Spanning Element
The spanner occupies a full-width region rather than being fragmented into individual columns.
Content After the Spanner
The browser starts a new multi-column section after the spanning element.
Example
.article {
column-count: 2;
column-gap: 30px;
}
.article .section-divider {
column-span: all;
padding: 15px 0;
}
Interaction with break-inside
.article .content-block {
break-inside: avoid;
}
The break-inside property can request that a content block remain together within a column, subject to fragmentation constraints. It does not make the block span columns.
Interaction with break-before
.article .new-section {
break-before: column;
}
The break-before property requests a fragmentation break. It is not a substitute for column-span: all, which creates a full-width spanning region.
Practical Consideration
Spanning elements can significantly change column heights and content distribution. Test layouts with realistic amounts of text.
Column Rules and Gaps
Column rules and gaps apply between adjacent columns, but they do not extend through spanning elements.
Column Rule Example
.article {
column-count: 3;
column-gap: 30px;
column-rule: 2px solid #cccccc;
}
Adding a Spanning Heading
.article h2 {
column-span: all;
}
Rule Interruption
The column rules appear between columns above and below the heading, but they do not run through the spanning element.
Column Gap Behavior
The spanning element is not confined to an individual column gap. It extends across the available width of the multi-column container.
Adding a Heading Border
.article h2 {
column-span: all;
padding-bottom: 10px;
border-bottom: 2px solid #0066cc;
}
A border on the spanning heading can provide a horizontal separator between the column sections.
Practical Consideration
Use column rules for vertical separation and borders on spanning elements when horizontal separation is needed.
Supported Elements
The column-span property applies to eligible in-flow block-level elements in a multi-column formatting context.
Block-Level Headings
.article h2 {
column-span: all;
}
Block-Level Containers
.article .notice {
column-span: all;
}
Figures
.article figure {
column-span: all;
}
Inline Elements
.article span {
column-span: all;
}
An ordinary inline span does not become a column spanner simply because this property is assigned.
Block-Level Conversion
.article .full-width-label {
display: block;
column-span: all;
}
Changing an eligible element to block-level layout can allow it to participate as a spanner when the other requirements are met.
Floated and Positioned Elements
Floated and absolutely positioned elements do not become spanning elements through column-span: all. Spanners must participate in the applicable in-flow layout.
Formatting Context Restrictions
The property does not turn arbitrary descendants of nested formatting contexts into spanners. In particular, elements inside nested block formatting contexts do not span an ancestor's columns merely by setting column-span: all.
Practical Consideration
Place spanning headings or containers directly in the relevant multi-column flow whenever possible. This keeps their behavior easier to understand and maintain.
Grid and Flexbox Comparison
The column-span property is designed for CSS multi-column layout, not CSS Grid or Flexbox.
Multi-column Spanning
.article {
column-count: 3;
}
.article h2 {
column-span: all;
}
CSS Grid Spanning
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.grid .heading {
grid-column: 1 / -1;
}
In Grid, the grid-column property can position an item across specific grid tracks.
Spanning Two Grid Columns
.grid .item {
grid-column: span 2;
}
CSS Grid supports numeric track spanning. The column-span property does not.
Flexbox
.flex {
display: flex;
flex-wrap: wrap;
}
.flex .heading {
flex-basis: 100%;
}
In a wrapping Flexbox layout, flex-basis: 100% can make a flex item occupy a full line, subject to other flex properties and available space.
Choosing the Right Layout
Use multi-column layout when content should flow automatically from one column to another. Use Grid when precise placement and spanning across specific tracks are required.
Responsive Layouts
Spanning elements can remain full-width as the number of columns changes at different viewport sizes.
Desktop Layout
.article {
column-count: 3;
column-gap: 30px;
}
.article h2 {
column-span: all;
}
Tablet Layout
@media (max-width: 900px) {
.article {
column-count: 2;
column-gap: 24px;
}
}
Mobile Layout
@media (max-width: 600px) {
.article {
column-count: 1;
}
}
Single-Column Behavior
When only one column is generated, a spanning heading still appears in its normal content position. There are no multiple columns to span visually.
Automatic Column Count
.article {
column-width: 240px;
column-gap: 30px;
}
.article h2 {
column-span: all;
}
The browser determines how many columns fit while spanning headings continue to separate the content into sections.
Disabling Spanning at a Breakpoint
@media (max-width: 600px) {
.article h2 {
column-span: none;
}
}
This can be useful when the heading should return to normal flow on smaller screens.
Practical Consideration
Test the spacing above and below spanning elements at each breakpoint. A layout that looks balanced with three columns may need different margins when reduced to one column.
Practical Uses
The column-span property is useful whenever selected content should extend across the full width of a multi-column container.
Article Headings
.article {
column-count: 3;
column-gap: 30px;
}
.article h2 {
column-span: all;
}
Documentation Sections
.documentation {
column-count: 2;
column-gap: 30px;
}
.documentation .section-title {
column-span: all;
}
Reference Introductions
.reference-content {
column-width: 250px;
column-gap: 25px;
}
.reference-content .introduction {
column-span: all;
}
Full-Width Notices
.article .notice {
column-span: all;
padding: 15px;
background-color: #eef5ff;
}
Full-Width Illustrations
.article figure {
column-span: all;
margin: 20px 0;
}
.article figure img {
max-width: 100%;
height: auto;
}
Section Dividers
.article .section-divider {
column-span: all;
border-top: 2px solid #cccccc;
padding-top: 15px;
}
When Not to Use
Do not use column-span when an item must span a specific number of columns. CSS Grid is better suited for that requirement.
column-span Example
The following example demonstrates how column-span: all allows section headings to extend across a two-column layout.
Each heading interrupts the column flow, creating a separate group of columns below it.
<div class="column-span-demo">
<h3>HTML Fundamentals</h3>
<p>HTML elements provide the structure of a web page. Headings organize content, paragraphs contain text, and links connect documents.</p>
<p>Attributes add information to HTML elements. They can identify elements, specify resources, and control behavior.</p>
<p>Semantic HTML helps browsers and assistive technologies understand the purpose of different parts of a document.</p>
<p>A well-structured document provides a foundation for styling and interactive features.</p>
<h3>CSS Fundamentals</h3>
<p>CSS controls the appearance of HTML elements. Selectors identify elements, and declarations specify their styles.</p>
<p>Properties such as color, margin, and padding control visual presentation and spacing.</p>
<p>Layout properties arrange content using normal flow, Flexbox, Grid, and multi-column formatting.</p>
<p>Media queries help layouts adapt to different screen sizes and user preferences.</p>
</div>
.column-span-demo {
column-count: 2;
column-gap: 30px;
column-rule: 1px solid #cccccc;
padding: 15px;
border: 1px solid #dddddd;
background-color: #f8f9fa;
}
.column-span-demo h3 {
column-span: all;
margin: 0 0 15px;
padding: 10px 12px;
background-color: #e5eef8;
color: #234b73;
font-size: 1.125rem;
}
.column-span-demo h3:not(:first-child) {
margin-top: 20px;
}
.column-span-demo p {
margin: 0 0 12px;
}
@media (max-width: 600px) {
.column-span-demo {
column-count: 1;
}
}
HTML Fundamentals
HTML elements provide the structure of a web page. Headings organize content, paragraphs contain text, and links connect documents.
Attributes add information to HTML elements. They can identify elements, specify resources, and control behavior.
Semantic HTML helps browsers and assistive technologies understand the purpose of different parts of a document.
A well-structured document provides a foundation for styling and interactive features.
CSS Fundamentals
CSS controls the appearance of HTML elements. Selectors identify elements, and declarations specify their styles.
Properties such as color, margin, and padding control visual presentation and spacing.
Layout properties arrange content using normal flow, Flexbox, Grid, and multi-column formatting.
Media queries help layouts adapt to different screen sizes and user preferences.
Both headings extend across the full width of the container because they use column-span: all.
The paragraphs following each heading are distributed into two columns. The column rule separates the columns but does not continue through the spanning headings.
Each heading creates a new multi-column section, allowing the browser to balance the content in each section independently.
On narrow screens, the media query changes the layout to a single column while preserving the heading order and document structure.
Accessibility
Spanning elements can improve the visual organization of multi-column content, but the HTML document structure should remain meaningful without CSS.
Preserve Heading Hierarchy
Use appropriate heading levels to identify sections. The column-span property does not change the semantic meaning of a heading.
Maintain Reading Order
Multi-column layout changes the visual presentation of content without changing its source order. Assistive technologies generally follow the document structure.
Avoid Excessive Fragmentation
Too many spanning elements can create short columns and frequent visual interruptions. Use them where they help readers understand the content.
Responsive Readability
Reduce the number of columns on narrow screens or at increased zoom levels to maintain readable line lengths.
Clear Section Boundaries
Use appropriate spacing, headings, and optional borders to distinguish sections rather than relying on the spanning layout alone.
Avoid Visual-Only Meaning
Do not depend on a full-width appearance to communicate important information. Provide meaningful text and semantic HTML.
Test Without CSS
The document should remain understandable when styles are disabled or unsupported.
Important Considerations
Keep the following points in mind when using column-span:
- Purpose: Allows eligible elements to span across all columns in a CSS multi-column layout.
- Initial value:
none. - Inheritance: The property is not inherited.
- Valid values:
noneandall. - none: Keeps the element in normal multi-column flow.
- all: Makes the element span the full multi-column container.
- Numeric values: Values such as
2and3are invalid. - Spanning scope: The property does not support spanning a selected number of columns.
- Eligible elements: Applies to in-flow block-level elements subject to formatting context restrictions.
- Inline elements: Ordinary inline elements do not become spanners simply by setting the property.
- Floats and positioning: Floated and absolutely positioned elements do not participate as column spanners.
- Formatting contexts: Nested formatting contexts can prevent descendants from spanning ancestor columns.
- Column sections: A spanning element divides the content into separate multi-column sections.
- Column balancing: Spanning elements can change how content is balanced between columns.
- Column rules: Decorative column rules do not extend through spanning elements.
- Column gaps: The spanner occupies the available container width rather than an individual column.
- Multiple spanners: More than one spanning element can be used within the same container.
- Single column: Spanning has no visible multi-column effect when only one column is generated.
- Responsive layouts: Spanning elements can remain in place as the number of columns changes.
- Animations: Changes between
noneandallare discrete. - Grid comparison: Use
grid-columnwhen an item must span a specific number of grid tracks. - Accessibility: Preserve semantic structure, logical reading order, and readable column widths.
Use column-span: all when a heading or other eligible block should separate and extend across the columns of a multi-column layout.
Browser Support
The column-span property is widely supported in current versions of Chrome, Edge, Firefox, and Safari.
The standard none and all values can be used without vendor prefixes in modern browsers.
Basic Example
.article {
column-count: 3;
column-gap: 30px;
}
.article h2 {
column-span: all;
}
Compatibility Considerations
Older browser versions may not support column-span: all consistently. When unsupported, the element remains in the normal column flow.
For current compatibility information, visit Can I Use? and search for column-span.
Progressive Enhancement
.article {
column-count: 2;
column-gap: 30px;
}
@supports (column-span: all) {
.article h2 {
column-span: all;
}
}
Feature queries can be used when spanning is an optional enhancement. A positive @supports result confirms that the declaration is recognized, but does not guarantee identical layout behavior in every browser.
Specifications
The column-span property is defined in CSS Multi-column Layout Module Level 1.
CSS Multi-column Layout Module Level 1
The specification defines the supported values, eligible elements, and how spanning elements divide multi-column content into separate sections.
