CSS column-span

The CSS column-span property allows content to span across multiple columns on a multi-column layout. This can be useful if you have a heading or other element within the multicol layout that needs to span across all columns.

An element that spans across multiple columns is called a spanning element.

Syntax

column-span: none | all

Possible Values

none
Specifies that the element does not span across multiple columns.
all
Specifies that the element should span across all columns. Therefore, it becomes a spanning element.

Basic Property Information

Initial Value
none
Applies To
block-level elements, except floating and absolutely positioned elements
Inherited?
No
Media
Visual

Example Code

Basic CSS

column-span: all;

Working Example within an HTML Document

<!doctype html>
<title>Example</title>
<style>
.multicol {
  background: beige;
  padding: 10px;

  /* Safari and Chrome */
  -webkit-column-count: 3;
  -webkit-column-rule: 2px dotted coral;

  /* Firefox */
  -moz-column-count: 3; 
  -moz-column-rule: 2px dotted coral;

  /* CSS3 */
  column-count: 3; 
  column-rule: 2px dotted coral;
  }

.multicol h3 {
  column-span: all;
  }
</style>
<div class="multicol">
  <h3>This heading spans across all three columns &mdash; this is achieved using the column-span property</h3>
  <p>The CSS column-span property allows content to span across multiple columns on a multi-column layout. Useful if you have a heading that needs to span across all columns. </p>
  <p>An element that spans across multiple columns is called a spanning element.</p>
  <p>Try changing the values to see the effect it has on this example.</p>
</div>

Try it with the Online Editor

This example uses vendor prefixes for the multi-column layout due to lack of browser support for the official standard at the time of writing.

CSS Specifications

Browser Support

The following table provided by Caniuse.com shows the level of browser support for this feature.

Vendor Prefixes

For maximum browser compatibility many web developers add browser-specific properties by using extensions such as -webkit- for Safari, Google Chrome, and Opera (newer versions), -ms- for Internet Explorer, -moz- for Firefox, -o- for older versions of Opera etc. As with any CSS property, if a browser doesn't support a proprietary extension, it will simply ignore it.

This practice is not recommended by the W3C, however in many cases, the only way you can test a property is to include the CSS extension that is compatible with your browser.

The major browser manufacturers generally strive to adhere to the W3C specifications, and when they support a non-prefixed property, they typically remove the prefixed version. Also, W3C advises vendors to remove their prefixes for properties that reach Candidate Recommendation status.

Many developers use Autoprefixer, which is a postprocessor for CSS. Autoprefixer automatically adds vendor prefixes to your CSS so that you don't need to. It also removes old, unnecessary prefixes from your CSS.

You can also use Autoprefixer with preprocessors such as Less and Sass.