This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
Adam's excellent guide "Building a loading bar component" covers all things about the progress
element. It's a good read because it covers HTML, CSS and JavaScript, and taught me something new!
Today I learned that progress
HTML elements are considered to be in an indeterminate state if you don't define a element value
.
But it's not only the progress
element that can have this state. It's:
- radio buttons in a group when no radio is selected
- checkboxes with an
indeterminate
JavaScript property settrue
- and the mentioned
progress
elements without a definedvalue
Why's that interesting? Indeterminate elements can be selected with the :indeterminate
pseudo-class. 😲 (yeah, I haven't seen that one before either).
See below that :indeterminate
matches all radio elements in a group if there's none preselected. Thus, the group has an indeterminate state.
If you select one radio, the group loses the indeterminate state, and the purple styling disappears.
[Interactive component: visit the article to see it...]
:indeterminate
is also cross-browser supported. 🎉
If you're looking at the compatibility table on MDN, it links to a very old Safari bug ticket. I tested the above demo and it worked fine.
Reply to Stefan
This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis
Stefan Judis | Sciencx (2022-03-30T22:00:00+00:00) How to match HTML elements with an indeterminate state (#tilPost). Retrieved from https://www.scien.cx/2022/03/30/how-to-match-html-elements-with-an-indeterminate-state-tilpost/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.