A boolean attribute in HTML is an attribute that represents true
or false
values. If an HTML tag contains a boolean attribute â no matter the value of that attribute â the attribute is set to true
on that element. If an HTML tag does not contain the attribute, the attribute is set to false
.
If the attribute is present, it can have one of the following forms:
attribute
, meaning its implicit value is the empty stringattribute=""
attribute="attribute"
, attribute="ATTRIBUTE"
Note: The strings "true" and "false" are invalid values. To set the attribute to false
, the attribute should be omitted altogether. Though modern browsers treat any string value as true
, you should not rely on that behavior.
Here's an example of a HTML boolean attribute checked
:
<!-- The following checkboxes will be checked on initial rendering -->
<input type="checkbox" checked />
<input type="checkbox" checked="" />
<input type="checkbox" checked="checked" />
<input type="checkbox" checked="Checked" />
<!-- The following checkbox will not be checked on initial rendering -->
<input type="checkbox" />
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3