HTML - Boolean Attribute

> (World Wide) Web - (W3|WWW) > HyperText markup Language (HTML)

1 - About

A number of attributes are boolean attributes. The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

The values “true” and “false” are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.

3 - Example

Here is an example of a checkbox that is checked and disabled. The checked and disabled attributes are the boolean attributes.

<label><input type=checkbox checked name=cheese disabled> Cheese</label>
 
This could be equivalently written as this:
 
<label><input type=checkbox checked=checked name=cheese disabled=disabled> Cheese</label>
 
<!--You can also mix styles; the following is still equivalent -->
 
<label><input type='checkbox' checked name=cheese disabled=""> Cheese</label>
Advertising

4 - Documentation / Reference

web/html/boolean.txt · Last modified: 2019/02/09 11:29 by gerardnico