:indeterminate

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

:indeterminateCSS擬似クラスセレクターで、未確定の状態にあるフォーム要素を表します。例えばチェックボックスで HTML の indeterminate 属性が true に設定されたもの、ラジオボタンでグループ内がすべて選択されていないもの、 <progress> 要素で中間の状態などです。

css
/* 未確定の状態にある <input> をすべて選択 */ input:indeterminate { background: lime; } 

このセレクターが対象とする要素は以下の通りです。

構文

:indeterminate 

チェックボックスとラジオボタン

この例では中間の状態にあるフォームの要素に特殊なスタイルを適用します。

HTML

html
<fieldset> <legend>Checkbox</legend> <div> <input type="checkbox" id="checkbox" /> <label for="checkbox">This checkbox label starts out lime.</label> </div> </fieldset> <fieldset> <legend>Radio</legend> <div> <input type="radio" id="radio1" name="radioButton" /> <label for="radio1">First radio label starts out lime.</label> </div> <div> <input type="radio" id="radio2" name="radioButton" /> <label for="radio2">Second radio label also starts out lime.</label> </div> </fieldset> 

CSS

css
input:indeterminate + label { background: lime; } 

JavaScript

js
const inputs = document.getElementsByTagName("input"); for (let i = 0; i < inputs.length; i++) { inputs[i].indeterminate = true; } 

結果

プログレスバー

HTML

html
<progress></progress> 

CSS

css
progress { margin: 4px; } progress:indeterminate { width: 80vw; height: 20px; } 

結果

仕様書

Specification
HTML
# selector-indeterminate
Selectors Level 4
# indeterminate-pseudo

ブラウザーの互換性

関連情報