:indeterminate

:indeterminate is a pseudo-class selector in CSS named for a state that is neither checked nor unchecked. It's that in-between state that we might consider the "Maybe" between "Yes" and "No" options. The state is not fully determined, hence the name: indeterminate.

Indeterminate Checkboxes

The most common place we might see this in play is with checkboxes in a form:

Inderterminate as a third checkbox state

There are a few quirky things about :indeterminate when it comes to checkboxes that are worth noting before digging into how it can be selected in CSS.

It cannot be set in the HTML

First off, there is no way to set a checkbox to an indeterminate state in HTML. In the opening example above, we were able to set the second checkbox to checked by explicitly saying so in the HTML.

<!-- This is checked by default -->
<input type="checkbox" checked>

It is only logical to assume we could do the same with an indeterminate state:

<!-- This does not work! -->
<input type="checkbox" indeterminate>

But, sadly, that is not the case so do not use that last example in your code.

At the time of this writing, Javascript is the only means for setting an indeterminate state on a checkbox. One way to go about it is to select a specific checkbox by ID:

var checkbox = document.getElementById("some-checkbox");
checkbox.indeterminate = true;

The limitation of the example above is that the checkbox can never get back to an indeterminate state once it changes to another state. Instead, we can rotate between checked, unchecked and indeterminate states:

<!-- Inline click handler, just for demo -->
<input type="checkbox" id="demo" onclick="toggle(this)">
function toggle(demo) {
  if (demo.readOnly) demo.checked=demo.readOnly=false;
  else if (!demo.checked) demo.readOnly=demo.indeterminate=true;
}

See the Pen Rotate Checkbox States by Geoff Graham (@geoffgraham) on CodePen.

It is purely a visual state

A checkbox still only counts whether it has been checked or unchecked, regardless of whether we have activated an indeterminate state. In other words, indeterminate masks the actual value of the checkbox and does not count as a value of its own.

It's default appearance is inconsistent across browsers

Like numeric inputs, an indeterminate state does not style consistently in every browser.

A comparison of how indeterminate renders across a few different browsers

Overall, however, here is the support for indeterminate checkboxes.

This browser support data is from Caniuse, which also reports this feature is in status.

Desktop

Google ChromeMozilla FirefoxInternet ExplorerOperaApple Safari
283.55.511.6

Mobile / Tablet

iOS SafariAndroidOpera MobileAndroid ChromeAndroid Firefox
No4.4375651

Indeterminate Radio Buttons

:indeterminate can apply to radio buttons at the group level, where the entire group is considered to be in an indeterminate state if no option is selected.

See the Pen Inderminate Radio Buttons by Geoff Graham (@geoffgraham) on CodePen.

We ought to note that using :indeterminate may not be the best choice as far as user experience goes.

Indeterminate Progress Bars

We can also apply :indeterminate to the <progress> element where no value has been explicitly set in the HTML. There's no need for Javascript, but styling the <progress> element is itself a tricky thing that requires a lot of work and consideration for cross-browser consistency.

See the Pen Indeterminate Progress Element by Geoff Graham (@geoffgraham) on CodePen.

:indeterminate Pseudo-Class Selector Browser Support

This browser support data is from Caniuse, which also reports this feature is in Unofficial or W3C "Note" status.

Desktop

Google ChromeMozilla FirefoxInternet ExplorerOperaApple Safari
42993.1

Mobile / Tablet

iOS SafariAndroidOpera MobileAndroid ChromeAndroid Firefox
3.22.1105651

More Information

This comment thread is closed. If you have important information to share, please contact us.
icon-closeicon-emailicon-linkicon-logo-staricon-menuicon-searchicon-staricon-tag