Open In App
Related Articles

HTML | DOM Style columnWidth Property

Improve Article
Improve
Save Article
Save
Like Article
Like

The columnWidth property in DOM is used to specify the width of the columns.

Syntax:

  • Return the columnWidth property:
    object.style.columnWidth
  • Set the columnWidth property:

    object.style.columnWidth = "auto | length | initial | inherit" 

Return Values: It returns a string value, which represents the column-width property of an element.

Property Values:

  • auto: Default value. The column width are going to be determined by the browser
  • length: A length that specifies the width of the columns
  • initial: Sets this property to its default value. Read about initial
  • inherit: Inherits this property from its parent element. Read about inherit
  • Example:




    <!DOCTYPE html>
    <html>
      
    <body>
        <center>
            <h1 style="color:green">GeeksforGeeks</h1>
            <h2>Style columnWidth Property</h2>
            <button onclick="GFGFun()">Click</button>
      
            <div id="DIVid">
                HTML stands for Hyper Text Markup Language.
              It is used to design web pages using markup language.
              HTML is the combination of Hypertext and 
              Markup language. Hypertext defines the link 
              between the web pages. Markup language is used 
              to define the text document within tag which 
              defines the structure of web pages. HTML is 
              a markup language which is used by the browser
              to manipulate text, images and other content 
              to display it in required format.
            </div>
      
            <script>
                function GFGFun() {
                  //Chrome, Safari, Opera
                    document.getElementById("DIVid").style.WebkitColumnWidth="50px"; 
                    // Firefox
                    document.getElementById("DIVid").style.MozColumnWidth="50px"; 
                    document.getElementById("DIVid").style.columnWidth="50px";
                }
            </script>
        </center>
    </body>
      
    </html>

    
    

    Output:
    Before:

    After:

    Supported Browsers: The browsers supported by HTML DOM Style columnWidth Property are listed below:

    • Google Chrome
    • Internet Explorer
    • Firefox MozColumnWidth
    • Apple Safari
    • Opera

    Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

    Last Updated : 25 Oct, 2021
    Like Article
    Save Article
    Previous
    Next
    Similar Reads
    Complete Tutorials