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:

AttributeBare =With value
hiddenhidden via display:noneuntil-found -- hidden but findable by Ctrl+F / fragment nav, auto-revealed
download ()download instead of navigatefilename hint: download="report.pdf"
sandbox (