Skip to content

Commit

Permalink
New page for HTMLInputElement.indeterminate (#35967)
Browse files Browse the repository at this point in the history
* New page for HTMLInputElement.indeterminate

* Update index.md

* Update index.md

* Add links

* Update files/en-us/web/api/htmlinputelement/indeterminate/index.md

Co-authored-by: Joshua Chen <[email protected]>

---------

Co-authored-by: Estelle Weyl <[email protected]>
  • Loading branch information
Josh-Cena and estelle authored Sep 20, 2024
1 parent 457e494 commit a497469
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
47 changes: 47 additions & 0 deletions files/en-us/web/api/htmlinputelement/indeterminate/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: "HTMLInputElement: indeterminate property"
short-title: indeterminate
slug: Web/API/HTMLInputElement/indeterminate
page-type: web-api-instance-property
browser-compat: api.HTMLInputElement.indeterminate
---

{{APIRef("HTML DOM")}}

The **`indeterminate`** property of the {{domxref("HTMLInputElement")}} interface returns a boolean value that indicates whether the checkbox is in the _indeterminate_ state. For example, a "select all/deselect all" checkbox may be in the indeterminate state when some but not all of its sub-controls are checked. The `indeterminate` state can only be set via JavaScript and is only relevant to [`checkbox`](/en-US/docs/Web/HTML/Element/input/checkbox) controls.

It is unrelated to the {{domxref("HTMLInputElement.checked")}} property, and an indeterminate checkbox can be either checked or unchecked. Being indeterminate only affects the checkbox's appearance (see example below), not its presence when submitted (which is controlled by the checkedness).

## Value

A boolean.

## Examples

```html
<input type="checkbox" id="indeterminate-checkbox" />
<label for="indeterminate-checkbox">Indeterminate checkbox</label>
```

```js
const checkbox = document.getElementById("indeterminate-checkbox");
checkbox.indeterminate = true;
```

{{EmbedLiveSample("examples", "", 200)}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{domxref("HTMLInputElement")}}
- {{domxref("HTMLInputElement.checked")}}
- {{HTMLElement("input")}}
- [Indeterminate state checkboxes](/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes)
- CSS {{cssxref(":indeterminate")}} property
6 changes: 3 additions & 3 deletions files/en-us/web/css/_colon_indeterminate/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ browser-compat: css.selectors.indeterminate

{{CSSRef}}

The **`:indeterminate`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) represents any form element whose state is indeterminate, such as checkboxes that have been set to an [`indeterminate`](/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes) state with JavaScript, radio buttons which are members of a group in which all radio buttons are unchecked, and {{HTMLElement("progress")}} elements with no `value` attribute.
The **`:indeterminate`** [CSS](/en-US/docs/Web/CSS) [pseudo-class](/en-US/docs/Web/CSS/Pseudo-classes) represents any form element whose state is indeterminate, such as checkboxes that have been set to an [`indeterminate`](/en-US/docs/Web/API/HTMLInputElement/indeterminate) state with JavaScript, radio buttons which are members of a group in which all radio buttons are unchecked, and {{HTMLElement("progress")}} elements with no `value` attribute.

```css
/* Selects any <input> whose state is indeterminate */
Expand All @@ -18,7 +18,7 @@ input:indeterminate {

Elements targeted by this selector are:

- [`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox) elements whose `indeterminate` property is set to `true` by [JavaScript](/en-US/docs/Web/JavaScript)
- [`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox) elements whose [`indeterminate`](/en-US/docs/Web/API/HTMLInputElement/indeterminate) property is set to `true`
- [`<input type="radio">`](/en-US/docs/Web/HTML/Element/input/radio) elements, when all radio buttons with the same `name` value in the form are unchecked
- {{HTMLElement("progress")}} elements in an indeterminate state

Expand Down Expand Up @@ -131,6 +131,6 @@ progress:indeterminate {

- [Web forms — Working with user data](/en-US/docs/Learn/Forms)
- [Styling web forms](/en-US/docs/Learn/Forms/Styling_web_forms)
- The [`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox) element's [`indeterminate`](/en-US/docs/Web/HTML/Element/input/checkbox#indeterminate_state_checkboxes) property
- The [`<input type="checkbox">`](/en-US/docs/Web/HTML/Element/input/checkbox) element's [`indeterminate`](/en-US/docs/Web/API/HTMLInputElement/indeterminate) property
- {{HTMLElement("input")}} and the {{domxref("HTMLInputElement")}} interface which implements it.
- The {{cssxref(":checked")}} CSS selector lets you style checkboxes based on whether they're checked or not
2 changes: 1 addition & 1 deletion files/en-us/web/html/element/input/checkbox/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Beyond accessibility, this is another good reason to properly set up `<label>` e

### Indeterminate state checkboxes

A checkbox can be in an **indeterminate** state. This is set using the {{domxref("HTMLInputElement")}} object's `indeterminate` property via JavaScript (it cannot be set using an HTML attribute):
A checkbox can be in an **indeterminate** state. This is set using the {{domxref("HTMLInputElement")}} object's [`indeterminate`](/en-US/docs/Web/API/HTMLInputElement/indeterminate) property via JavaScript (it cannot be set using an HTML attribute):

```js
inputInstance.indeterminate = true;
Expand Down

0 comments on commit a497469

Please sign in to comment.