The compact attribute is a boolean hint that a list should render with reduced spacing. It appeared on <ol>, <ul>, <dl>, and <menu>. Interpretation was always browser-specific.
For new pages, use CSS — for example line-height: 80% (a common stand-in) or tighter margin on list items.
Obsolete.
Do not use compact in new HTML. Authors must not use it. Learn it to read legacy markup; ship CSS for spacing.
Syntax
HTML Syntax
syntax.html
<ulcompact> … </ul>
Same boolean form on <ol>, <dl>, and <menu>. Presence turns the hint on; no value is required.
Values
Attribute Values
Boolean attribute — only presence matters:
Value
Description
Try it
(present)
Hint: render the list more compactly (browser-defined)
Modern browsers may show normal spacing — that is expected.
How It Works
Boolean attribute — write compact with no value (or compact="compact").
Hint only — the browser decides whether spacing changes.
List content is unchanged; only presentation was affected historically.
Obsolete today — keep for reading old pages, not for new ones.
Example 2 — ol and dl
The same hint applied to ordered and description lists.
HTML
<ol compact>
<li>Mix the dry ingredients.</li>
<li>Add the wet ingredients.</li>
<li>Bake for 20 minutes.</li>
</ol>
<dl compact>
<dt>HTML</dt>
<dd>Markup language for pages.</dd>
<dt>CSS</dt>
<dd>Styles for presentation.</dd>
</dl>
Same idea as the stylesheet example: line-height: 80%.
How It Works
Class + CSS separates structure from presentation.
line-height: 80% is the stand-in suggested for a compact look.
Predictable across browsers — unlike the old attribute.
Tune further with margin / padding on li when needed.
Edge Cases & Pitfalls
Treat compact as historical — CSS is the reliable way to tighten lists.
obsolete
Not for new HTML
Validators flag it. Remove compact when you touch old templates and replace with CSS.
visual
Often ignored
If your list looks the same with or without compact, that is normal in current browsers.
scope
Lists only
Not a global attribute. Putting it on <div> or <p> is invalid.
a11y
Keep tap targets readable
Very tight line-height can hurt readability. Compact should still stay usable.
dir
Obsolete <dir>
Old docs may show compact on <dir>. Prefer <ul> today.
Compatibility
Browser Support
compact is an obsolete HTML attribute on list elements. Engines may still expose it in the DOM, but visual effect is unreliable.
✓ Obsolete · Do not use
compact
Listed as obsolete for ol, ul, dl, and menu. Prefer CSS line-height or margins for compact lists.
LegacyCompatibility only
Google ChromeAttribute may exist; little/no effect
Obsolete*
Mozilla FirefoxAttribute may exist; little/no effect
Obsolete*
Apple SafariAttribute may exist; little/no effect
Obsolete*
Microsoft EdgeAttribute may exist; little/no effect
Obsolete*
OperaAttribute may exist; little/no effect
Obsolete*
Samsung InternetAttribute may exist; little/no effect
Obsolete*
Internet ExplorerLegacy compact list styling
Legacy*
compactObsolete (often ignored)
Bottom line: *Do not use in new pages. Migrate list spacing to CSS.
Remember
Key Takeaways
Role: boolean hint for tighter list spacing.
Status: obsolete — study for legacy HTML only.
Elements:ol, ul, dl, menu.
Replace with: CSS line-height / margin.
One line: learn compact for old lists — ship CSS spacing instead.
Frequently Asked Questions
It is a boolean hint that a list (ol, ul, dl, or menu) should render with reduced spacing. How that looks was always browser-specific.
Obsolete. The HTML Living Standard says authors must not use it. Prefer CSS such as line-height: 80% (MDN’s suggested stand-in) or tighter margins on list items.
Historically ol, ul, dl, and menu (and the obsolete dir element). It is not a global attribute.
It is a boolean attribute: present means “compact”; absent means default spacing. Writing compact="compact" is the same as compact.
Modern browsers often ignore it. That is expected — use CSS for real spacing control.
Use CSS line-height, margin, and padding on the list or its items. Do not rely on the compact attribute in new pages.