CSS :indeterminate
Pseudo-Class
The :indeterminate
pseudo-class applies styles to checkboxes, radio buttons, and progress bars that are in an uncertain state (neither checked nor unchecked).
1. Syntax
✅ Targets elements that are not explicitly checked or unchecked.
2. When to Use :indeterminate
?
-
Checkboxes that are in a mixed/partially selected state.
-
Radio buttons that have no selection yet.
-
Progress bars with an unknown completion percentage.
3. Example – Indeterminate Checkbox (Partial Selection)
✅ The parent checkbox turns orange when some (but not all) child checkboxes are checked.
š” JavaScript to Make Checkbox Indeterminate
✅ The parent checkbox becomes indeterminate when some children are checked.
4. Example – Indeterminate Progress Bar
✅ The progress bar gets a gray background when its value is not set.
5. Browser Support
✅ Fully supported in Chrome, Edge, Firefox, Safari, and Opera.
6. Best Practices
✔ Use :indeterminate
for checkboxes in tree structures (e.g., folder selection).
✔ Combine with JavaScript for dynamic UI behavior.
✔ Use on <progress>
elements when loading time is unknown.