/

HTML / CSS / JavaScript Tutorial

CSS Property: column-span

[this page | pdf | back links]

The CSS (CSS3) column-span property specifies how many columns an element should span across.

 

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

 

Value

Description

1

(default value). Element should span across one column

all

Element should span across all columns

 

Default Value:

1

JavaScript syntax:

e.g. object.style.columnSpan="all"

Inherited:

No

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 200px; column-count: 2;}
h3.x1 {column-span: all; text-align: center;}
</style>
</head>
<body>
Note: not all element types seem to support this property effectively
1. Element with default property<br>
<div><h3>title</h3>Some text that may be broken into several columns</div><br><br>
2. Element set using in-file HTML style
<div><h3 class="x1">title</h3>Some text that may be broken into several columns</div><br><br>
3. Element set using JavaScript
<div><h3 id="x2">title</h3>Some text that may be broken into several columns</div>

<script>
document.getElementById("x2").style.columnSpan = "all";
document.getElementById("x2").style.textAlign = "center";
</script>

</body>
</html>

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


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile