Element.ariaLevel is an instance property that reflects the aria-level attribute. Learn how it stores a hierarchical level as a string integer, when to prefer native <h1>–<h6> headings, and how to get or set the property from JavaScript—with five examples and try-it labs.
01
Kind
Instance property
02
Type
String (integer)
03
Example
"1" · "2" · "3"
04
Reflects
aria-level
05
Status
Baseline widely
06
Common with
role="heading"
Fundamentals
Introduction
Documents and widgets often have hierarchy: page title, section title, nested tree items. Assistive technologies need to know which level an item sits at in that structure.
aria-level carries that number as a string. ariaLevel is the JavaScript reflection of that attribute.
JavaScript
const el = document.getElementById("main-heading");
console.log(el.ariaLevel); // "1"
el.ariaLevel = "2";
💡
Beginner tip (MDN)
Where possible, use an HTML <h1> (or other correct heading level). Native headings already expose hierarchy and do not need ARIA attributes. Reach for role="heading" plus ariaLevel mainly when you cannot use a real heading element.
Concept
Understanding the Property
MDN: the ariaLevel property of the Element interface reflects the value of the aria-level attribute, which defines the hierarchical level of an element within a structure.
Reflected attribute — mirrors aria-level.
Get / set — readable and writable string containing an integer.
Hierarchy — level within headings, trees, and similar structures.
Baseline — widely available since October 2023 (MDN).
Foundation
📝 Syntax
JavaScript
ariaLevel
Value
A string containing an integer.
Example
Meaning
"1"
Top / first level (often like h1)
"2"
Second level (often like h2)
"3"
Third level, and so on
⚠️
Prefer native headings
If you can write <h2>Section title</h2>, do that instead of role="heading" aria-level="2". ARIA is a bridge when native HTML is not available.
Pattern
📋 MDN Example Shape
MDN starts with role="heading" and aria-level="1", then updates the level to "2" with the property:
JavaScript
<div role="heading" id="main-heading" aria-level="1">
This is a main page heading
</div>
JavaScript
let el = document.getElementById("main-heading");
console.log(el.ariaLevel); // "1"
el.ariaLevel = "2";
console.log(el.ariaLevel); // "2"
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Read
el.ariaLevel
Set level
el.ariaLevel = "2"
Value shape
String integer ("1", "2", …)
Prefer when possible
Native <h1>–<h6>
Common pairing
role="heading"
MDN status
Baseline Widely available
Snapshot
🔍 At a Glance
Four facts about Element.ariaLevel.
Kind
get / set
Instance
Type
string
Integer text
Reflects
aria-level
Attribute
Baseline
widely
Oct 2023+
Hands-On
Examples Gallery
Examples follow MDN Element: ariaLevel. Labs use a role="heading" element so you can safely read and write the property.
📚 Getting Started
Read the reflected value and follow MDN’s update.
Example 1 — Read ariaLevel
Log the hierarchical level from a custom heading.
JavaScript
const el = document.getElementById("main-heading");
console.log(el.ariaLevel);
// HTML includes: role="heading" aria-level="1"
Prefer ariaLevel in script; keep the attribute for HTML markup.
Example 5 — Support Snapshot
Feature-detect and remember the native-heading preference.
JavaScript
console.log({
supported: "ariaLevel" in Element.prototype,
type: "string containing an integer",
tip: "Prefer native h1–h6 when possible (MDN)",
status: "Baseline Widely available (MDN)"
});
Element.ariaLevel 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.ariaLevel
String integer — reflects aria-level for hierarchical level within a structure.
BaselineWidely available
Google ChromeSupported (ARIA reflection)
Yes
Microsoft EdgeSupported (ARIA reflection)
Yes
Mozilla FirefoxSupported (ARIA reflection)
Yes
Apple SafariSupported (ARIA reflection)
Yes
OperaFollow Chromium support
Yes
Internet ExplorerNo ariaLevel IDL — use setAttribute
No
ariaLevelBaseline
Bottom line: Use ariaLevel to declare hierarchy for ARIA heading (and similar) roles. Prefer native HTML headings when you can. Keep the value as a string integer such as "1" or "2".
Wrap Up
Conclusion
ariaLevel reflects aria-level so hierarchical widgets can expose their depth as a string integer. Reach for native headings first; use this property when ARIA heading roles (or other leveled roles) are the only option.
Use aria-level on elements that are not hierarchical
Forget a clear accessible name on the heading text
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about ariaLevel
Reflected aria-level string for hierarchical level.
5
Core concepts
📄01
Get / set
on Element
Kind
📝02
String integer
"1" "2" "3"
Type
🔍03
Prefer h1–h6
when possible
MDN
✅04
Baseline
widely available
Status
🎯05
heading role
common pairing
Use
❓ Frequently Asked Questions
It reflects the aria-level attribute as a string containing an integer, which defines the hierarchical level of an element within a structure.
No. MDN marks Element.ariaLevel as Baseline Widely available (since October 2023). It is not Deprecated, Experimental, or Non-standard.
A string containing an integer, for example "1", "2", or "3".
No when you can avoid it. MDN recommends using HTML heading elements (h1–h6) where possible because they have built-in semantics and do not require ARIA attributes.
When you use role="heading" (or other hierarchical roles such as treeitem) and need to declare the level in the accessibility tree.
Yes. Reading and writing ariaLevel updates the reflected aria-level attribute.
Did you know?
aria-level is not only for headings. Roles like treeitem can also use it to express nesting depth. Still start with the simplest native HTML that matches your structure.