Skip to content
Related Articles

Related Articles

HTML | DOM Style columnGap Property
  • Last Updated : 31 Jul, 2019
GeeksforGeeks - Summer Carnival Banner

The DOM Style columnGap property specifies the gap between the columns.

Syntax :

  • For return the value:
    object.style.columnGap
    
  • For set the value:
    object.style.columnGap = "length|normal|initial|inherit"
    

Property Values:

  • length: Set the column gap in length unit.
  • normal: The default value of column gap.
  • initial: Sets the default value.
  • inherit: Inherit property from parent element.

Return Value : This will return a String representing the column-gap property of an element.

  1. Length: This specifies a length that will set the gap between the columns.
    Example-1:






    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
            HTML | DOM Style columnGap Property
        </title>
        <style>
            #myDIV {
                width: 600px;
                height: 70%;
                border: 2px solid green;
                padding: 10px;
                column-count: 3;
            }
              
            #p1 {
                font-size: 20px;
                color: green;
            }
        </style>
    </head>
      
    <body>
      
        <div id="myDIV">
            <p id="p1">
              <u>Welcome to GeeksforGeeks.!</u
              An operating system acts as an intermediary
              between the user of a computer and computer 
              hardware. The purpose of an operating system
              is to provide an environment in which a user
              can execute programs in a convenient and 
              efficient manner. An operating system is 
              software that manages the computer hardware. 
              The hardware must provide appropriate mechanisms
              to ensure the correct operation of the computer 
              system and to prevent user programs from 
              interfering with the proper operation of the system.
            </p>
        </div>
        <br>
      
        <input type="button" onclick="mainFunction()" 
                                                value="Submit" />
        <script>
            function mainFunction() {
      
                //  Set columnGap in length.
                document.getElementById(
                    "myDIV").style.columnGap = "100px";
            }
        </script>
      
    </body>
      
    </html>

    Output:

    • Before Click:

    • After Click:

  2. normal: This specifies a normal gap between the columns.
    Example-2:




    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
            HTML | DOM Style columnGap Property
        </title>
        <style>
            #myDIV {
                width: 600px;
                height: 70%;
                border: 2px solid green;
                padding: 10px;
                column-count: 3;
                column-gap: 100px;
            }
              
            #p1 {
                font-size: 20px;
                color: green;
            }
        </style>
    </head>
      
    <body>
      
        <div id="myDIV">
            <p id="p1">
              <u>Welcome to GeeksforGeeks.!</u
              An operating system acts as an intermediary
              between the user of a computer and computer 
              hardware. The purpose of an operating system
              is to provide an environment in which a user
              can execute programs in a convenient and 
              efficient manner. An operating system is 
              software that manages the computer hardware. 
              The hardware must provide appropriate mechanisms
              to ensure the correct operation of the computer 
              system and to prevent user programs from 
              interfering with the proper operation of the system.
            </p>
        </div>
        <br>
          
          
        <input type="button" onclick="mainFunction()"
         value="Submit" />
        <script>
            function mainFunction() {
              
                //  Set columnGap to normal.
                document.getElementById(
                "myDIV").style.columnGap = "normal";
            }
        </script>
      
    </body>
      
    </html>

    Output:

    • Before Click:

    • After Click:

  3. initial: This sets this property to its default value.
    Example-3:






    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
            HTML | DOM Style columnGap Property
        </title>
        <style>
            #myDIV {
                width: 600px;
                height: 70%;
                border: 2px solid green;
                padding: 10px;
                column-count: 3;
                column-gap: 100px;
            }
              
            #p1 {
                font-size: 20px;
                color: green;
            }
        </style>
    </head>
      
    <body>
      
        <div id="myDIV">
            <p id="p1">
                <u>Welcome to GeeksforGeeks.!</u>
              An operating system acts as an intermediary
              between the user of a computer and computer 
              hardware. The purpose of an operating system 
              is to provide an environment in which a user 
              can execute programs in a convenient and 
              efficient manner. An operating system is
              software that manages the computer hardware.
              The hardware must provide appropriate mechanisms
              to ensure the correct operation of the computer
              system and to prevent user programs from 
              interfering with the proper operation of the 
              system.
            </p>
        </div>
        <br>
      
        <input type="button" onclick="mainFunction()" 
                                             value="Submit" />
      
        <script>
            function mainFunction() {
      
                //  set columnGap into normal.
                document.getElementById(
                    "myDIV").style.columnGap = "initial";
            }
        </script>
      
    </body>
      
    </html>

    Output:

    • Before Click:

    • After Click:

  4. inherit: This inherits this property from its parent element.
    Example-4:




    <!DOCTYPE html>
    <html>
      
    <head>
        <title>
            HTML | DOM Style columnGap Property
        </title>
        <style>
            #myDIV {
                width: 600px;
                height: 60%;
                border: 2px solid green;
                padding: 10px;
                column-count: 3;
                column-gap: 100px;
            }
              
            #p1 {
                column-gap: 50px;
            }
        </style>
    </head>
      
    <body>
      
        <div id="myDIV">
            <p id="p1">
                <u style="color: green ;
                          font-size: 20px;">
                  Welcome to GeeksforGeeks.!</u>
      
              <br>
              An operating system acts as an intermediary
              between the user of a computer and computer 
              hardware. The purpose of an operating system 
              is to provide an environment in which a user
              can execute programs in a convenient and 
              efficient manner. An operating system is 
              software that manages the computer hardware.
              The hardware must provide appropriate mechanisms 
              to ensure the correct operation of the computer 
              system and to prevent user programs from 
              interfering with the proper operation of the 
              system.
            </p>
        </div>
        <br>
      
        <input type="button" onclick="mainFunction()" 
                                             value="Submit" />
      
        <script>
            function mainFunction() {
      
                //  Set columnGap "inherit".
                document.getElementById(
                    "myDIV").style.columnGap = "inherit";
            }
        </script>
      
    </body>
      
    </html>

    Output:

    • Before Click:

    • After Click:

Note: Use MozColumnRule for Mozilla Firefox.

Supported Browsers: The supported browser by HTML | DOM Style columnGap Property
are listed below:

  • Google Chrome
  • Edge
  • Opera
  • Safari

full-stack-img

My Personal Notes arrow_drop_up
Recommended Articles
Page :