Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS3 Multiple Columns

CSS3 Multiple Columns

CSS3 can design text content into a newspaper-like multi-column layout, as in the following example:

Runoob Tutorial - Learning is not only about technology, but also about dreams! Runoob Tutorial (www.runoob.com) provides the most comprehensive basic tutorials on programming technologies, introducing the basics of various programming languages such as HTML, CSS, JavaScript, Python, Java, Ruby, C, PHP, MySQL, etc. The site also provides a large number of online examples, through which you can better learn programming.


Browser support

The numbers in the table indicate the first browser version that supports this method.

The -webkit- or -moz- following a number is the prefix for the specified browser.

property
column-count 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit-
11.1
column-gap 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit-
11.1
column-rule 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit-
11.1
column-rule-color 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit
11.1
column-rule-style 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit
11.1
column-rule-width 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit
11.1
column-width 4.0 -webkit- 10.0 2.0 -moz- 3.1 -webkit- 15.0 -webkit
11.1

CSS3 Multi-column Properties

In this chapter we will learn the following CSS3 multi-column properties:


CSS3 Creating Multiple Columns

column-count The property specifies the number of columns to divide the content into.

The following example divides the

text in the element into 3 columns:

Example

div

{

   

-webkit-column-count:

3;

/* Chrome, Safari, Opera */

   

-moz-column-count:

3;

/* Firefox */

   

column-count:

3;

}

Try it »


CSS3 Gap Between Columns

column-gap The property specifies the gap between columns.

The following example specifies a 40-pixel gap between columns:

Example

div

{

   

-webkit-column-gap:

40px;

/* Chrome, Safari, Opera */

   

-moz-column-gap:

40px;

/* Firefox */

   

column-gap:

40px;

}

Try it »


CSS3 Column Borders

column-rule-style The property specifies the border style between columns:

Example

div

{

   

-webkit-column-rule-style:

solid;

/* Chrome, Safari, Opera */

   

-moz-column-rule-style:

solid;

/* Firefox */

   

column-rule-style:

solid;

}

Try it »

column-rule-width The property specifies the border width between columns:

Example

div

{

   

-webkit-column-rule-width:

1px;

/* Chrome, Safari, Opera */

   

-moz-column-rule-width:

1px;

/* Firefox */

   

column-rule-width:

1px;

}

Try it »

column-rule-color The property specifies the border color between columns:

Example

div

{

   

-webkit-column-rule-color:

lightblue;

/* Chrome, Safari, Opera */

   

-moz-column-rule-color:

lightblue;

/* Firefox */

   

column-rule-color:

lightblue;

}

Try it »

column-rule The property is a shorthand for all the column-rule-* properties.

The following example sets the width, style, and color of the border between columns:

Example

div

{

   

-webkit-column-rule:

1px solid lightblue;

/* Chrome, Safari, Opera */

   

-moz-column-rule:

1px solid lightblue;

/* Firefox */

   

column-rule:

1px solid lightblue;

}

Try it »


Specify how many columns an element should span

The following example specifies that the

element spans all columns:

Example

h2

{

   

-webkit-column-span:

all;

/* Chrome, Safari, Opera */

   

column-span:

all;

}

Try it »


Specifies the width of columns.

column-width The property specifies the width of the columns.

Example

div

{

   

-webkit-column-width:

100px;

/* Chrome, Safari, Opera */

   

column-width:

100px;

}

Try it »


CSS3 Multi-column Properties

The following table lists all CSS3 multi-column properties:

property Description
column-count Specifies the number of columns an element should be divided into.
column-fill Specifies how columns are filled.
column-gap Specifies the gap between columns
column-rule Shorthand for all column-rule-* properties
column-rule-color Specifies the color of the border between columns
column-rule-style Specifies the style of the border between columns
column-rule-width Specifies the width of the border between columns
column-span Specifies how many columns an element should span
column-width Specifies the width of columns.
columns Shorthand property for column-width and column-count.