The CSS3 multi-column layout allows easy definition of multiple columns of text - just like in newspapers:
CSS3 Multi-column Properties
In this chapter you will learn about the following multi-column properties:
CSS3 Create Multiple Columns
The column-count property specifies the number of columns an element should be divided into.
The following example will divide the text in the <div> element into 3 columns:
Example
CSS3 Specify the Gap Between Columns
The column-gap property specifies the gap between the columns.
The following example specifies a 40 pixels gap between the columns:
Example
CSS3 Column Rules
The column-rule-style property specifies the style of the rule between columns:
Example
The column-rule-width property specifies the width of the rule between columns:
Example
Example
The column-rule property is a shorthand property for setting all the column-rule-* properties above.
The following example sets the width, style, and color of the rule between columns:
Example
Specify How Many Columns an Element Should Span
The column-span property specifies how many columns an element should span across.
The following example specifies that the <h2> element should span across all columns:
Example
Specify The Column Width
The column-width property specifies a suggested, optimal width for the columns.
The following example specifies that the suggested, optimal width for the columns should be 100px:
Example
CSS3 Multi-columns Properties
The following table lists all the multi-columns properties:
CSS3 Multi-column Properties
In this chapter you will learn about the following multi-column properties:
- column-count
- column-gap
- column-rule-style
- column-rule-width
- column-rule-color
- column-rule
- column-span
- column-width
CSS3 Create Multiple Columns
The column-count property specifies the number of columns an element should be divided into.
The following example will divide the text in the <div> element into 3 columns:
Example
div {
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */
column-count: 3;
}
Try it Yourself »
CSS3 Specify the Gap Between Columns
The column-gap property specifies the gap between the columns.
The following example specifies a 40 pixels gap between the columns:
Example
div {
-webkit-column-gap: 40px; /* Chrome, Safari, Opera */
-moz-column-gap: 40px; /* Firefox */
column-gap: 40px;
}
Try it Yourself »
CSS3 Column Rules
The column-rule-style property specifies the style of the rule between columns:
Example
div {
-webkit-column-rule-style: solid; /* Chrome, Safari, Opera */
-moz-column-rule-style: solid; /* Firefox */
column-rule-style: solid;
}
Try it Yourself »
The column-rule-width property specifies the width of the rule between columns:
Example
div {
-webkit-column-rule-width: 1px; /* Chrome, Safari, Opera */
-moz-column-rule-width: 1px; /* Firefox */
column-rule-width: 1px;
}
Try it Yourself »The column-rule-color property specifies the color of the rule between columns:
Example
div {
-webkit-column-rule-color: lightblue; /* Chrome, Safari, Opera */
-moz-column-rule-color: lightblue; /* Firefox */
column-rule-color: lightblue;
}
Try it Yourself »
The column-rule property is a shorthand property for setting all the column-rule-* properties above.
The following example sets the width, style, and color of the rule 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 Yourself »
Specify How Many Columns an Element Should Span
The column-span property specifies how many columns an element should span across.
The following example specifies that the <h2> element should span across all columns:
Example
h2 {
-webkit-column-span: all; /* Chrome, Safari, Opera */
column-span: all;
}
Try it Yourself »
Specify The Column Width
The column-width property specifies a suggested, optimal width for the columns.
The following example specifies that the suggested, optimal width for the columns should be 100px:
Example
div {
-webkit-column-width: 100px; /* Chrome, Safari, Opera */
-moz-column-width: 100px; /* Firefox */
column-width: 100px;
}
Try it Yourself »
CSS3 Multi-columns Properties
The following table lists all the multi-columns properties:
Property
|
Description
|
---|---|
column-count | Specifies the number of columns an element should be divided into |
column-fill | Specifies how to fill columns |
column-gap | Specifies the gap between the columns |
column-rule | A shorthand property for setting all the column-rule-* properties |
column-rule-color | Specifies the color of the rule between columns |
column-rule-style | Specifies the style of the rule between columns |
column-rule-width | Specifies the width of the rule between columns |
column-span | Specifies how many columns an element should span across |
column-width | Specifies a suggested, optimal width for the columns |
columns | A shorthand property for setting column-width and column-count |