Att Ol Compact
π
2026-06-14 | π HTML
# HTML
compact Attribute
The `` `compact` attribute is a legacy HTML attribute used to render an ordered list in a more compact form by reducing the line spacing and indentation of the list items.
---
## Introduction
In older versions of HTML, the `compact` attribute was used to hint to the browser that the list should be displayed as compactly as possible. This was particularly useful for long lists where screen space was limited.
However, **this attribute is deprecated in HTML 4.01 and is not supported in HTML5**. Modern web development standards dictate that all presentational styling should be handled via CSS rather than HTML attributes.
---
## Browser Support
| Attribute | Chrome | Edge/IE | Firefox | Safari | Opera |
| :--- | :--- | :--- | :--- | :--- | :--- |
| `compact` | β Not Supported | β Not Supported | β Not Supported | β Not Supported | β Not Supported |
> **Note:** Almost all modern web browsers have dropped support for the `compact` attribute. Using it will have no visual effect on your web pages.
---
## Syntax and Usage
### Legacy HTML Syntax
In HTML 4.01, `compact` is a boolean attribute:
```html
- Coffee
- Tea
- Milk
```
### Legacy XHTML Syntax
In XHTML, attribute minimization is forbidden, meaning the attribute must be defined with its value:
```html
- Coffee
- Tea
- Milk
```
---
## Modern CSS Alternatives
Since the `compact` attribute is obsolete, you should use CSS to achieve a compact list layout. You can control the spacing of your list items by adjusting the `line-height`, `margin`, and `padding` properties.
### Example: Reducing Line Height and Margins with CSS
To make an ordered list compact using modern standards, apply the following CSS styles:
```html
Modern Compact List Example
Standard Ordered List
- Coffee
- Tea
- Milk
Compact Ordered List (CSS Alternative)
- Coffee
- Tea
- Milk
```
---
## Key Differences and Considerations
* **HTML5 Compatibility:** The `compact` attribute is completely obsolete in HTML5. Pages using it will fail HTML5 validation.
* **Separation of Concerns:** HTML is meant for structure, while CSS is meant for presentation. Adjusting list spacing is a presentational task, making CSS the correct tool for the job.
* **Flexibility:** Using CSS allows you to precisely control the spacing (e.g., `line-height: 80%` or `margin: 0`) across different screen sizes using media queries, which was impossible with the rigid `compact` attribute.