Coder Perfect

In HTML, is there a checkbox for the three states?

Problem

Isn’t there no way to have a tri-state check button in HTML (yes, no, null)?

Are there any simple tricks or workarounds that may be used instead of having to render the entire thing from scratch?

Asked by Pekka

Solution #1

I found a better way thanks to Janus Troelsen’s comment:

See the W3C reference guide for more information. Set the checkbox to true to make it look visually indeterminate:

element.indeterminate = true;

Janus Troelsen’s fiddle is shown here. However, keep in mind the following:

Previous answer

Answered by pau.moreno

Solution #2

On input elements, you might use HTML’s indeterminate IDL attribute.

Answered by Ms2ger

Solution #3

My suggestion is to make use of

See examples at:

Answered by Wolfgang Fahl

Solution #4

You can get this feature by using radio groups:

<input type="radio" name="choice" value="yes" />Yes
<input type="radio" name="choice" value="No" />No
<input type="radio" name="choice" value="null" />null

Answered by Franz

Solution #5

Indeterminate states can be used: http://css-tricks.com/indeterminate-checkboxes/. Browsers support it out of the box, and it doesn’t require any other js libraries.

Answered by altso

Post is based on https://stackoverflow.com/questions/1726096/tri-state-check-box-in-html