HTML5 Boolean Attributes

Published
July 13, 2026

Boolean Attributes are a special kind of attribute in HTML which acts as a yes/no switch.

Typically the understanding is that if the attribute exists at all, with any value whatsoever, that it is considered as a "true" state. If it does not exist, then "false."

However the reality is that the rules are inconsistent here, and vary by attribute.

These variations split into two distinct traps.

1. Presence is meaningful, but a value refines it

These act boolean (just writing the attribute does something), yet an optional value changes the behavior:

Attribute

Bare =

With value

hidden

hidden via display:none

until-found -- hidden but findable by Ctrl+F / fragment nav, auto-revealed

download ()

download instead of navigate

filename hint: download="report.pdf"

sandbox (</code>)</td><td>maximum restrictions</td><td>token list <em>relaxing</em> them: <code>sandbox="allow-scripts allow-forms"</code></td></tr><tr><td><code>crossorigin</code></td><td>same as <code>anonymous</code></td><td><code>anonymous</code> | <code>use-credentials</code></td></tr><tr><td><code>capture</code> (<code><input type=file></code>)</td><td>prefer a camera/mic</td><td><code>user</code> | <code>environment</code> (which camera)</td></tr><tr><td><code>popover</code></td><td>same as <code>auto</code></td><td><code>auto</code> | <code>manual</code> | <code>hint</code></td></tr><tr><td><code>preload</code> (media)</td><td>same as <code>auto</code></td><td><code>none</code> | <code>metadata</code> | <code>auto</code></td></tr></tbody></table><p>Note <code>sandbox</code> is backwards from intuition: adding tokens <em>loosens</em> it.</p><h3>2. Look boolean, but <code>="false"</code> actually works</h3><p>This is the nastier category, because it inverts the rule you learn from <code>disabled</code>/<code>checked</code> (where <code>disabled="false"</code> still disables):</p><ul type="list"><li><code>contenteditable</code> -- <code>true</code> | <code>false</code> | <code>plaintext-only</code>; bare = true</li><li><code>spellcheck</code> -- <code>true</code> | <code>false</code></li><li><code>draggable</code> -- <code>true</code> | <code>false</code> (bare is <em>invalid</em>; default is auto)</li><li><code>translate</code> -- <code>yes</code> | <code>no</code></li><li><code>writingsuggestions</code>, <code>autocorrect</code> -- <code>true</code> | <code>false</code></li></ul><p>So <code><div contenteditable="false"></code> is genuinely not editable, while <code><input disabled="false"></code> is still disabled. Same-looking syntax, opposite outcomes.</p><h3>The actually-pure booleans</h3><p>Value is ignored entirely for: <code>disabled</code>, <code>checked</code>, <code>readonly</code>, <code>required</code>, <code>multiple</code>, <code>selected</code>, <code>open</code>, <code>autofocus</code>, <code>novalidate</code>, <code>formnovalidate</code>, <code>async</code>, <code>defer</code>, <code>nomodule</code>, <code>ismap</code>, <code>reversed</code>, <code>loop</code>, <code>muted</code>, <code>autoplay</code>, <code>controls</code>, <code>playsinline</code>, <code>default</code>, <code>inert</code>, <code>allowfullscreen</code>, <code>itemscope</code>, <code>shadowrootclonable</code>.</p><p>For all of these, the only way to turn them off is to <strong>remove the attribute</strong> -- which is why frameworks special-case them (React drops the attribute on <code>false</code>, Vue does the same for its known boolean list).</p>

Table of Contents
Comments
Did we just make your life better?
Passion drives our long hours and late nights supporting the Webflow community. Click the button to show your love.