You are here: Reference > JavaScript > client-side > style handling > properties > browser specific extensions > MozColumnCount

MozColumnCount style property | webkitColumnCount style property

Browser support:
MozColumnCount
webkitColumnCount
Specifies or retrieves the number of columns that the contents of the element should be flowed into.

Syntax:

object.MozColumnCount;
object.webkitColumnCount;
You can find the related objects in the Supported by objects section below.
MozColumnCount: This property is read/write.
webkitColumnCount: This property is read/write.
CSS page for this property: -moz-column-count

Possible values:

The type of this property is string.
 One of the following values: 
auto
The browser renders the contents automatically.
inherit
Takes the value of this property from the computed style of the parent element.
number of columns (positive integer)
Integer, the number of columns.
Default: auto.

Example HTML code 1:

This example illustrates the use of the -moz-column-count and the -webkit-column-count properties:
<head>
    <style>
        .example {
            -moz-column-count: 2;
            -webkit-column-count: 2;
        }
    </style>
</head>
<body>
    <div class="example">
        You can order the text content of an element into one or more columns with the 
        -moz-column-count and the -webkit-column-count properties.
        Resize the window!
    </div>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the MozColumnCount and webkitColumnCount properties in JavaScript:
<head>
    <script type="text/javascript">
        function ChangeColumnCount (selectTag) {
            // Returns the index of the selected option
            var whichSelected = selectTag.selectedIndex;

            // Returns the text of the selected option
            var columnCount = selectTag.options[whichSelected].text;

            var div = document.getElementById ("myDiv");

            if ('MozColumnCount' in div.style) {
                div.style.MozColumnCount = columnCount;
            } else if ('webkitColumnCount' in div.style) {
                div.style.webkitColumnCount = columnCount;
            } else {
                alert ("Your browser doesn't support this example!");
            }
        }
    </script>
</head>
<body>
    <div id="myDiv">
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
        Sed libero purus, nonummy et, viverra a, vestibulum eu, mauris. 
        Quisque consectetuer venenatis elit. Etiam lorem lectus, 
        lobortis malesuada, elementum quis, consequat at, eros. 
        Ut scelerisque faucibus velit.
    </div>

    <select onchange="ChangeColumnCount (this);" size="6">
        <option selected="selected" />auto
        <option />2
        <option />4
        <option />6
        <option />7
        <option />14
    </select>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content