Sometimes when it’s false, it’s true
A short posts on boolean attributes in HTML. What’s a boolean attribute? Something that can only be
true or false
false; things like:
They either are reversed, checked or disabled, or they’re not.
The funny thing about booleans in HTML is that they’re true if they exist. So even if the value is
required="false") it’s still true!
In fact, it doesn’t matter what value a boolean attribute is given:
required="banana" do the same thing.
You can go one step further an remove the value altogether, leaving just
required, and that’s what I do. It differentiates a boolean nicely from other attributes like