Skip to main content
InterviewHubPRO
Section Overview
Q37

Question 37 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

74%
Web Accessibility & WCAG (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Focus Traps and the Native `inert` Attribute.

senior LevelCode ExampleSystem Design

In Simple Words: When a modal opens, keyboard focus must stay trapped inside the modal so pressing Tab doesn't cycle through invisible background links.

  • The Modern Native Solution: Add the HTML boolean attribute inert to background containers (<main inert>). The browser natively disables all pointer events, keyboard focus, and screen reader visibility for that subtree!
html
<!-- Native Accessible Modal Background Isolation -->
<header inert></header>
<main inert></main>

<!-- Only modal is active and reachable via keyboard -->
<div role="dialog" aria-modal="true" aria-labelledby="modal-title">
  <h2 id="modal-title">Edit Profile</h2>
  <button>Save</button>
  <button id="close-btn">Close</button>
</div>