/

HTML / CSS / JavaScript Tutorial

CSS Property: column-count

[this page | pdf | back links]

The CSS (CSS3) column-count property specifies the number of columns an element (e.g. a paragraph) should be divided into.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

auto

(default value). Number of columns will be determined by other properties such as column-width

number

Optimum number of columns into which content of element will be formatted

 

Default Value:

auto

JavaScript syntax:

e.g. object.style.columnCount=2

Inherited:

No

Animatable:

Yes

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
p {width: 200px;}
p.x1 {column-count: 2;}
</style>
</head>
<body>
1. Element with default property<br>
<p>Some text that may be broken into several columns</p><br><br>
2. Element set using in-file HTML style
<p class="x1">Some text that may be broken into several columns</p><br><br>
3. Element set using JavaScript
<p id="x2">Some text that may be broken into several columns</p>

<script>
document.getElementById("x2").style.columnCount = "2";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyColumnCount() {
  var x = document.createElement("DIV"); x.style.columnCount = "2"; return (window.getComputedStyle(x, null).columnCount == "2");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile