JavaScript Element ariaSort Property

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.ariaSort is an instance property that reflects the aria-sort attribute. Learn the ascending, descending, none, and other values, how sortable column headers use it, and how to get or set the property from JavaScript—with five examples and try-it labs.

01

Kind

Instance property

02

Type

String

03

Values

ascending · descending · none · other

04

Reflects

aria-sort

05

Status

Baseline widely

06

Used on

Column headers

Introduction

Data tables often let users click a column header to sort rows—A–Z, Z–A, newest first, and so on. Assistive technologies need to know which column is sorted and in which direction.

aria-sort carries that signal on a column header. ariaSort is the JavaScript reflection of that attribute.

JavaScript
const el = document.getElementById("role-heading");
console.log(el.ariaSort); // "none"
el.ariaSort = "ascending";
💡
Beginner tip

When one column becomes sorted, set its ariaSort to ascending or descending, and set other sortable headers back to none. Match the visual sort arrow too.

Understanding the Property

MDN: the ariaSort property of the Element interface reflects the value of the aria-sort attribute, which indicates if items in a table or grid are sorted in ascending or descending order.

  • Reflected attribute — mirrors aria-sort.
  • Get / set — readable and writable string.
  • Four tokensascending, descending, none, other.
  • Baseline — widely available since October 2023 (MDN).

📝 Syntax

JavaScript
ariaSort

Value

A string with one of the following values:

ValueMeaning (MDN)
"ascending"Items are sorted in ascending order by this column.
"descending"Items are sorted in descending order by this column.
"none"There is no defined sort applied to the column.
"other"A sort algorithm other than ascending or descending has been applied.
⚠️
Sort the data, then announce it

ariaSort does not sort the rows by itself. Your script (or server) must reorder the data; ariaSort only tells assistive technologies which sort is active.

📋 MDN Column Header Shape

MDN starts with a column header marked aria-sort="none", then updates it to "ascending" with the property:

JavaScript
<th
  role="columnheader"
  id="role-heading"
  aria-sort="none"
  aria-rowindex="1"
  aria-colindex="1">
  ARIA Role
</th>
JavaScript
let el = document.getElementById("role-heading");
console.log(el.ariaSort); // "none"
el.ariaSort = "ascending";
console.log(el.ariaSort); // "ascending"

Related learning: ariaRowCount, ariaColIndex, and ariaRowIndex for table/grid models.

⚡ Quick Reference

GoalCode / note
Readel.ariaSort
Ascendingel.ariaSort = "ascending"
Descendingel.ariaSort = "descending"
Clear sortel.ariaSort = "none"
Custom sortel.ariaSort = "other"
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.ariaSort.

Kind
get / set

Instance

Type
string

4 tokens

Reflects
aria-sort

Attribute

Baseline
widely

Oct 2023+

Examples Gallery

Examples follow MDN Element: ariaSort. Labs use a role="columnheader" so you can safely read and write the property.

📚 Getting Started

Read the reflected value and follow MDN’s sort update.

Example 1 — Read ariaSort

Log the current sort state from a column header.

JavaScript
const el = document.getElementById("role-heading");
console.log(el.ariaSort);

// HTML includes: role="columnheader" aria-sort="none"
Try It Yourself

How It Works

The property returns the attribute string. If the attribute is missing, many browsers return null.

Example 2 — MDN Update to "ascending"

MDN: change from no sort to ascending.

JavaScript
let el = document.getElementById("role-heading");
console.log(el.ariaSort); // "none"
el.ariaSort = "ascending";
console.log(el.ariaSort); // "ascending"
Try It Yourself

How It Works

Assigning the property updates the reflected aria-sort attribute so assistive technologies hear the new sort direction. Also reorder the table rows to match.

📈 Toggle Direction, Attribute Sync & Snapshot

Practice ascending/descending and verify reflection.

Example 3 — Toggle Ascending / Descending

Flip sort direction on a second click (common UI pattern).

JavaScript
const el = document.createElement("th");
el.setAttribute("role", "columnheader");
el.setAttribute("aria-sort", "ascending");
el.textContent = "Name";
document.body.appendChild(el);

el.ariaSort = el.ariaSort === "ascending" ? "descending" : "ascending";
console.log({
  ariaSort: el.ariaSort,
  tip: "Clear other headers to none when this one becomes active"
});
Try It Yourself

How It Works

Toggle between ascending and descending on the active column. Keep sibling headers at none unless you intentionally support multi-column sort (then consider other).

Example 4 — Property vs getAttribute

Confirm the attribute stays in sync after a write.

JavaScript
const el = document.createElement("th");
el.setAttribute("role", "columnheader");
el.setAttribute("aria-sort", "none");
el.textContent = "ARIA Role";
document.body.appendChild(el);

el.ariaSort = "descending";
console.log({
  fromProperty: el.ariaSort,
  fromAttribute: el.getAttribute("aria-sort"),
  same: el.ariaSort === el.getAttribute("aria-sort")
});
Try It Yourself

How It Works

Prefer ariaSort in script; keep the attribute for HTML markup.

Example 5 — Support Snapshot

Feature-detect and list the allowed tokens.

JavaScript
console.log({
  supported: "ariaSort" in Element.prototype,
  allowed: ["ascending", "descending", "none", "other"],
  tip: "Sort the rows in the DOM; ariaSort only announces the state",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Do not let ARIA sort disagree with the visible order or sort icons—mismatched sort state confuses AT users.

🚀 Common Use Cases

  • Sortable data tables and ARIA grids.
  • Announcing A–Z vs Z–A when a header is clicked.
  • Clearing other columns to none when a new sort becomes active.
  • Marking custom sort modes with other.
  • Keeping script and markup aligned without manual setAttribute.

🔧 How It Works

1

User clicks a header

Or activates it with keyboard.

Input
2

Rows are reordered

Your code sorts the data in the table/grid.

Data
3

ariaSort updates

Active header gets ascending/descending; others none.

State
4

Assistive tech announces sort

Users hear which column is sorted and how.

📝 Notes

Browser Support

Element.ariaSort is Baseline Widely available (MDN: across browsers since October 2023). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.ariaSort

String — reflects aria-sort (ascending / descending / none / other).

Baseline Widely available
Google Chrome Supported (ARIA reflection)
Yes
Microsoft Edge Supported (ARIA reflection)
Yes
Mozilla Firefox Supported (ARIA reflection)
Yes
Apple Safari Supported (ARIA reflection)
Yes
Opera Follow Chromium support
Yes
Internet Explorer No ariaSort IDL — use setAttribute
No
ariaSort Baseline

Bottom line: Use ariaSort on columnheaders to announce table/grid sort direction. Keep only one active sort column when that matches your UI. Sort the data yourself; ariaSort only reflects the state.

Conclusion

ariaSort reflects aria-sort so column headers can declare how a table or grid is sorted. Use the string tokens, keep visuals in sync, and always sort the underlying rows when the state changes.

Continue with ariaValueMax, ariaSetSize, ariaRowCount, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use the four string tokens exactly
  • Match ARIA sort to the visible order and icons
  • Set inactive headers to none
  • Make headers keyboard-activatable
  • Reorder rows when sort changes

❌ Don’t

  • Expect ariaSort to sort the table for you
  • Leave multiple columns as ascending/descending by mistake
  • Invent custom token spellings
  • Forget to update sort after a new click
  • Hide sort state from sighted users only

Key Takeaways

Knowledge Unlocked

Five things to remember about ariaSort

Reflected aria-sort string for table/grid column sort direction.

5
Core concepts
📝 02

String tokens

4 allowed values

Type
🔍 03

Columnheader

table / grid

Use
04

Baseline

widely available

Status
🎯 05

Announce only

you sort the data

Tip

❓ Frequently Asked Questions

It reflects the aria-sort attribute as a string that indicates whether items in a table or grid are sorted in ascending or descending order (or none/other) for that column header.
No. MDN marks Element.ariaSort as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
One of the strings "ascending", "descending", "none", or "other".
On columnheader elements in a table or grid that users can sort. Usually only one column is actively sorted at a time.
A sort algorithm other than ascending or descending has been applied (for example a custom or multi-key sort).
Yes. Reading and writing ariaSort updates the reflected aria-sort attribute.
Did you know?

MDN’s demo puts aria-sort on a real role="columnheader" inside a semantic ARIA table—so sort state lives on the header that users activate, not on the table root.

Next: Element ariaValueMax

Learn the reflected aria-valuemax property for range widget maximums.

ariaValueMax →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful