Course contentsShow
← Web Development
Lesson 1048 of 2,98219. Keyboard Navigation and FocusFree lesson

Disabled and inert Attribute Effects

How disabled removes elements from tab order and the inert attribute for entire subtrees.

Disabled and inert Attribute Effects

You'll learn how disabled and inert remove elements from keyboard navigation, keeping users from accessing parts of your interface.

Understanding disabled

When you add the disabled attribute to a form control (like a button, input, or select), two important things happen:

  1. The element is removed from the tab order — keyboard users skip right over it
  2. The element becomes non-interactive — clicks and other inputs are ignored

Think of disabled like a light switch that's been covered with a childproof plate. It's still visible, but nobody can interact with it.

<button disabled>Save Changes</button>
<input type="text" disabled value="Read-only content">

These elements won't receive keyboard focus and screen readers typically announce them as "disabled" or "unavailable."

The inert Attribute: Disabling Entire Sections

While disabled works on individual form controls, inert is more powerful — it makes an entire subtree of elements non-interactive and invisible to assistive technologies.

When you mark an element as inert:

  • All descendants are removed from tab order
  • They cannot be clicked or focused
  • Screen readers skip the entire section
  • Even links and buttons inside become inert
<div inert>
  <h2>Loading...</h2>
  <button>Click me</button> <!-- Won't work -->
  <a href="/page">Link</a> <!-- Won't work -->
</div>

This is perfect for content behind modals, loading overlays, or temporarily hidden sections. It's like putting a whole room off-limits rather than locking individual items.

Key Takeaway: Use disabled to remove individual form controls from interaction and tab order; use inert to disable entire sections of content, including all their descendants, from keyboard navigation and assistive technologies.