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

MozColumnWidth style property | webkitColumnWidth style property

Browser support:
MozColumnWidth
webkitColumnWidth
Specifies or retrieves the suggested width of columns. The width of a column may be different from this value depending on its contents.

Syntax:

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

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.
width in non-negative length
The width of the column in length units. For the supported length units, see the length page.
Default: auto.

Example HTML code 1:

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

Example HTML code 2:

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

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

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

            if ('MozColumnWidth' in div.style) {
                div.style.MozColumnWidth = columnWidth;
            } else if ('webkitColumnWidth' in div.style) {
                div.style.webkitColumnWidth = columnWidth;
            } 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="ChangeColumnWidth (this);" size="6">
        <option selected="selected" />auto
        <option />5em
        <option />10em
        <option />15em
        <option />20em
        <option />30em
    </select>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content