Open In App

HTML DOM ol compact Property

The HTML DOM ol compact Property is used to set or return a value of the compact attribute in <ol> tag. The compact attribute is used to define the list that should be smaller than normal by reducing the space between the list items and the indentation of the list. It is a Boolean attribute.

Note: This property is not supported by HTML5.



Syntax: 

olObject.compact
olObject.compact = "True/false";

Property Values:



Return Values: It returns a Boolean value that represents whether the compact property is set to true or false.

Example: In this example, we will use the  HTML DOM ol compact Property




<!DOCTYPE html>
<html>
 
<head>
    <title>
          HTML DOM ol compact Property
      </title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2> HTML DOM ol compact Property </h2>
    <ol id="Geeks" type="1" compact>
       
        <!-- Assigning id to 'li tag' -->
        <li id="GFG">Geeks</li>
        <li>Sudo</li>
        <li>Gfg</li>
        <li>Gate</li>
        <li>Placement</li>
    </ol>
    <button onclick="myGeeks()">
          Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            // return ol compact Property
            let g = document.getElementById(
                "Geeks").compact;
            document.getElementById(
                "sudo").innerHTML = g;
        }
    </script>
   
</body>
 
</html>

Output: 

 

Example 2: In this example, we will use the  HTML DOM ol compact Property




<!DOCTYPE html>
<html>
 
<head>
    <title>
          HTML DOM ol compact Property
      </title>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2> HTML DOM ol compact Property </h2>
    <ol id="Geeks" type="1" compact>
       
        <!-- Assigning id to 'li tag' -->
        <li id="GFG">Geeks</li>
        <li>Sudo</li>
        <li>Gfg</li>
        <li>Gate</li>
        <li>Placement</li>
    </ol>
    <button onclick="myGeeks()">
          Submit
      </button>
    <p id="sudo"></p>
   
    <script>
        function myGeeks() {
            // set ol compact Property
            let g = document.getElementById(
                "Geeks").compact = "false";
            document.getElementById(
                "sudo").innerHTML = g;
        }
    </script>
   
</body>
 
</html>

Output: 

 

Supported Browsers: The HTML DOM ol compact property is not supported by any major browsers.


Article Tags :