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

HTML Reference Manual

HTML Tag Reference

HTML dir compact attribute

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

 HTML <dir> tag

Online Example

Using the compact attribute in a directory list:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <dir> <compact> Attribute Usage-Basic Tutorial(oldtoolbag.com)</title>
</head>
<body>
<dir compact>
  <li>html</li>
  <li>xhtml</li>
  <li>css</li>
</dir>
<p>Compact attribute is not supported by any major browser</p>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Note: Currently, all mainstream browsers do not support the compact attribute.

Definition and Usage

The <dir> tag in HTML5is no longer supported. Please use CSS instead.

The compact attribute of <dir> in HTML 4.01 is deprecated.

The compact attribute is a boolean (boolean) attribute.

The compact attribute specifies that the list is presented in a smaller size than normal, which is achieved by reducing the line spacing and indenting the list.

Compatibility note

The compact attribute of <dir> in HTML 4.01 is deprecated. Please use CSS instead.

CSS syntax: <dir style="line-height: 80%">

CSS Example: Reduce the line height of the list

You can find more about it in our CSS tutorial:line-height propertyDetails of attributes.

Differences between HTML and XHTML

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

Syntax

<dir compact>

 HTML <dir> tag