The "inert" attribute is finally coming to the web (#blogPost)

There are UI scenarios when you want to make particular page areas inaccessible to whoever clicks around. For example: let’s assume you fade in a modal dialog asking the user if they want to delete their account?
Do you want them to…


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

There are UI scenarios when you want to make particular page areas inaccessible to whoever clicks around. For example: let's assume you fade in a modal dialog asking the user if they want to delete their account?

Do you want them to interact with inputs while this question hangs around? Most likely not.

But how do you prevent people from doing precisely this? Covering the page with a faded-in semi-transparent div won't cut it because it's still possible to tab around and focus other areas and elements on the page using the keyboard. Folks using assistive technology might miss the dialog and navigate away, not realizing that their account is up for deletion.

The dialog element is soon cross-browser supported and can help with modal focus handling.

Or to name another example: if you navigated sites with the keyboard you might have found yourself tabbing into offscreen and invisible areas. A sliding side navigation could be invisible to you but accessible via the keyboard. This situation is just confusing and no great user experience.

Read the inert explainer if you want to learn more about inert use cases.

What you're looking for in these scenarios is a way to make page areas inaccessible. Rendered DOM elements shouldn't be focusable, clickable, editable, or selectable. They should become inaccessible.

That's where inert comes into play!

[Interactive component: visit the article to see it...]

The inert attribute makes entire subtrees inaccessible

I honestly didn't believe inert would enter the web anymore because I initially heard of the HTML attribute years ago.

But now, Safari Tech Preview ships it with v143, Chrome will enable the attribute with Chrome 102 in May and Firefox implements the feature behind the html5.inert.enabled flag.

Browsers are on a roll lately, and inert is part of it!

MDN Compat Data (source)
Browser support info for inert attribute
chrome chrome_android edge firefox firefox_android safari safari_ios samsunginternet_android webview_android
60* 60* 79* 81* 81* preview* Non

If you want to start using it today, don't sweat it! There's also an official polyfill available.


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2022-04-08T22:00:00+00:00) The "inert" attribute is finally coming to the web (#blogPost). Retrieved from https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/

MLA
" » The "inert" attribute is finally coming to the web (#blogPost)." Stefan Judis | Sciencx - Friday April 8, 2022, https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/
HARVARD
Stefan Judis | Sciencx Friday April 8, 2022 » The "inert" attribute is finally coming to the web (#blogPost)., viewed ,<https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/>
VANCOUVER
Stefan Judis | Sciencx - » The "inert" attribute is finally coming to the web (#blogPost). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/
CHICAGO
" » The "inert" attribute is finally coming to the web (#blogPost)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/
IEEE
" » The "inert" attribute is finally coming to the web (#blogPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/. [Accessed: ]
rf:citation
» The "inert" attribute is finally coming to the web (#blogPost) | Stefan Judis | Sciencx | https://www.scien.cx/2022/04/08/the-inert-attribute-is-finally-coming-to-the-web-blogpost/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.