Input

Pseudo-classes which apply to form elements:

  • :autofill applies once an element has been autofilled by the browser.
  • :enabled applies if the user can interact with the control.
  • :disabled applies if the control is disabled.
  • :read-only applies if the control is disabled or read-only; the user can't edit the input's value.
  • :read-write applies if the input is not disabled or read-only.
  • :placeholder-shown matches inputs showing placeholder text.
  • :default matches inputs that are default:
    • `option` elements match if they're selected or the first enabled option in a `select`.
    • `input` match if type is checkbox or radio and the element has the checked attribute.
    • `button` matches if it's a form's primary submit button; the first button in the DOM that belongs to the form.
  • :checked applies to checkboxes and radio buttons that are selected.
  • :indeterminate applies to checkboxes with the indeterminate attribute set.
  • :blank matches an input containing an empty string or other null/empty input.
  • :valid matches inputs with valid contents.
  • :invalid matches inputs with invalid contents.
  • :in-range applies to range inputs with a value in the permitted range.
  • :out-of-range applies to range inputs with a value outside the permitted range.
  • :required matches required inputs.
  • :optional matches optional inputs.
  • :user-invalid matches inputs which are invalid, but only once a user has interacted with it.

Backlinks