English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML reference manual

HTML tag大全

HTML: <ul> compact attribute

The compact attribute is a boolean attribute. When present, it specifies that the list should be smaller than normally displayed by reducing the space between lines and the list indentation.

 HTML <ul> tag

Online example

Use the compact attribute in an unordered list:

<ul compact>
  <li>apple</li>
  <li>grape</li>
  <li>melon</li>
  <li>pineapple</li>
</ul>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

All mainstream browsers do not support the compact attribute.

Definition and Usage

HTML5 does not support the <ul> compact attribute. Use CSS instead.

The compact attribute of <ul> in HTML 4.01 deprecated.

The compact attribute is a boolean attribute.
When present, it specifies that the list should be displayed smaller than normal by reducing the space between lines and the indentation of the list.

Compatibility Comments

in HTML 4.01 disapproved the use of the compact attribute of the ul element; in XHTML 1Strict DTD does not support the compact attribute of the ul element.

CSS Syntax: <ul style="line-height: 80%">

CSS Example: Reduce the line height in the list

In our CSS tutorial, you can find more about line-height attribute details.

Differences between HTML and XHTML

In XHTML, attributes are not allowed to be abbreviated, and the compact attribute must be defined as: <ul compact="compact">.

Syntax

<ul compact>
 HTML <ul> tag