Skip to main content

CSS Column Rules

This page covers CSS column rules, span, and width properties.


CSS Column Rule

The column-rule-style property sets the style of the vertical line between columns. The column-rule-width property sets the width of that line. The column-rule-color property sets its color. The column-rule property is a shorthand for setting all three at once.

Rule style

Use column-rule-style to add a solid vertical rule between columns.

Prompt
Create a page with a div containing multiple paragraphs of text, split into 3 columns using column-count. Apply column-rule-style: solid to show a solid vertical rule between the columns.
Output: complete HTML page

Rule width

Use column-rule-width to set the width of the vertical rule between columns.

Prompt
Create a page with a div containing multiple paragraphs of text, split into 3 columns using column-count. Apply column-rule-style: solid and column-rule-width: 1px to set the width of the vertical rule between columns.
Output: complete HTML page

Rule color

Use column-rule-color to set the color of the vertical rule between columns.

Prompt
Create a page with a div containing multiple paragraphs of text, split into 3 columns using column-count. Apply column-rule-style: solid and column-rule-color: lightblue to color the vertical rule between columns.
Output: complete HTML page

Rule shorthand

Use the column-rule shorthand to set the width, style, and color of the vertical rule in one declaration.

Prompt
Create a page with a div containing multiple paragraphs of text, split into 3 columns using column-count. Use the column-rule shorthand property set to "1px solid lightblue" to style the vertical rule between columns.
Output: complete HTML page

CSS Column Span

The column-span property sets how many columns an element should span across. This is often used for headings.

Example

Make an <h2> element span across all columns and center it.

Prompt
Create a page with a div split into 3 columns containing paragraphs of text. Add an h2 heading inside the div with column-span: all and text-align: center, so the heading spans across all columns.
Output: complete HTML page

CSS Column Width

The column-width property sets a suggested, optimal width for each column. The browser decides how many columns to create based on this width and the available space.

Example

Set the suggested optimal column width to 100px and let the browser determine the number of columns.

Prompt
Create a page with a div containing multiple paragraphs of text. Use column-width: 100px to let the browser determine the number of columns based on the suggested optimal width and available space.
Output: complete HTML page