Skip to content
Marcos Caceres edited this page Mar 27, 2026 · 13 revisions

data-sort

Applies to: <ol>, <ul>, <dl>

Sorts the top-level items of a list alphabetically. Useful for dependency sections, IDL member definitions, glossaries, and any list that should stay alphabetically ordered.

Usage

<ul data-sort>
  <li>Banana</li>
  <li>Apple</li>
  <li>Cherry</li>
</ul>
<dl data-sort="descending">
  <dt>Banana</dt><dd>A yellow fruit.</dd>
  <dt>Apple</dt><dd>A red or green fruit.</dd>
  <dt>Cherry</dt><dd>A small red fruit.</dd>
</dl>

Values

Value Sorts
"ascending" A → Z (default when attribute has no value)
"descending" Z → A

Notes

  • Sorting is shallow — only the top-level items are sorted; nested lists are untouched
  • For <dl>, the <dt> is used as the sort key; associated <dd> elements move with their <dt>
  • Sorting is locale-aware (uses JavaScript's Intl.Collator)

Guides

Configuration options

W3C Configuration options

Linting rules

Internal properties

Handled by ReSpec for you.

Special <section> IDs

HTML elements

Custom Elements

HTML attributes

CSS Classes

Special properties

Clone this wiki locally