HTML inert Global Attribute
Description
The inert attribute in HTML is a global attribute that you can use with any element. It essentially makes that element and all its content inactive, meaning users can't interact with it and assistive technologies like screen readers will ignore it.
Here's a breakdown of what inert does:
- Stops user interaction: Clicking, focusing, or other actions on the element won't trigger any events.
- Hides from assistive tech: Screen readers and other tools won't announce or navigate to the inert content.
- Removes from accessibility tree: The element is excluded from the accessibility tree, which helps assistive technologies understand the page structure.
Think of inert as a way to temporarily turn off a section of your webpage. It's useful for things like:
- Modal windows: When a modal window is open, you can make the rest of the page inert to prevent users from accidentally interacting with it.
- Content that's loading or disabled: You can use
inerton content that's still loading or is currently unavailable. - Decorative elements: For elements that are purely visual and don't serve an interactive purpose,
inertcan help ensure they don't confuse assistive technologies.
It's important to note that inert is generally used for larger sections of content. For individual controls that you want to disable, consider using the disabled attribute along with CSS styling for the disabled state.
Syntax
<element inert>
Values
- No Values
Example
Browser Support
The following information will show you the current browser support for the HTML inert global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.
This global attribute is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 24th March 2024
