HTML - DOM Style Object columns Property



HTML DOM Style Object columns property is a shorthand property of columnWidth and columnCount property, and used to set thee column Width and column Count.

Syntax

Set the columns property:
object.style.columns= "auto | column-width | column-count | initial | inherit";
Get the columns property:
object.style.columns;

Property Values

Value Description
auto It is the default value which sets both count and width to auto.
columnWidth It sets the column width.
columnCount It specifies the number of column in which the element will be broken into.
initial It is used to set this property to it's default value.
inherit It is used to inherit the property of it's parent element.

Return Value

It returns a string value which represents column property of an element.

Example of HTML DOM Style Object 'columns' Property

The following example sets column width and defines column count using columns property.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>
        HTML DOM Style Object columns Property
    </title>
</head>
<body>
    <p>Click to set column count and width.</p>
    <button onclick="fun()">Click</button>
    <p id="color">
        CSS is the acronym for "Cascading Style Sheet".
        It's a style sheet language used for describing
        the presentation of a document written in a markup
        language like HTML. CSS helps the web developers to
        control the layout and other visual aspects of the
        web pages. CSS plays a crucial role in modern web
        development by providing the tools necessary to create
        visually appealing, accessible, and responsive websites.
    </p>
    <script>
        function fun() {
            document.getElementById("color")
                .style.columns = "45px 4";
        }
    </script>
</body>
</html>

Supported Browsers

Property Chrome Edge Firefox Safari Opera
columns Yes 50 Yes 12 Yes 52 Yes 9 Yes 11.1
html_dom.htm
Advertisements