The indeterminate pseudo-class

The indeterminate pseudo-class defines a style of switches that are in an indeterminate state, i.e. not checked.

Syntax

cssselector:indeterminate {
  
}

Example

Let's recolor the text font green when the checkbox is in an indeterminate state:

html<form>
  <p>
    <input type="checkbox">
      <span>Text</span>
  </p>
</form>
cssinput:indeterminate, input:indeterminate + span {
  color: green;
}
input, span {
  color: black;
}
javascriptdocument.getElementsByTagName('input')[0].indeterminate = true;

Результат:

See also

  • the :default pseudo-class
    that sets a default style for elements
  • the :optional pseudo-class
    that sets a style for the input that does not have a required attribute
  • the :placeholder-shown pseudo-class
    that sets a style for elements when displaying tooltip text
  • the :read-only pseudo-class
    that sets a style for inputs that cannot be changed
  • the :required pseudo-class
    that sets a style of the input that has the required attribute set
  • the :focus-within pseudo-class
    that styles the elements in focus
  • the caret-color property
    that sets a color of the text cursor in input