HTML <ol> compact Attribute

Last Updated : 22 May, 2026

The HTML <ol> compact attribute was used to display an ordered list in a more compact form with reduced spacing between items. 

  • Used with the <ol> tag for compact list display.
  • It reduced the space between list items.

Syntax:

 <ol compact>

Note: The HTML <ol> compact attribute is not supported by HTML 5 instead of using this we can use the CSS line-height property.

html
<!--Driver Code Starts-->

<!DOCTYPE html> 
<html> 

<head> 
    <title>
        HTML ol compact Attribute
    </title> 
</head> 

<!--Driver Code Ends-->

<body> 
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    
    <h3>HTML &lt;ol&gt; compact Attribute</h3> 

    

<p>Compact attribute</p>
 
    <ol compact> 
        <li>HTML</li> 
        <li>CSS</li> 
        <li>JS</li> 
    </ol> 
</body> 

<!--Driver Code Starts-->

</html>                    

<!--Driver Code Ends-->
  • <ol compact>: Creates a numbered list; compact made it take less vertical space (obsolete now).
  • Content: Lists HTML, CSS, JS under a green “GeeksforGeeks” heading.
Comment