html5 – 当一个属性是一个布尔属性时,在HTML 5中是什么意思?

前端之家收集整理的这篇文章主要介绍了html5 – 当一个属性是一个布尔属性时,在HTML 5中是什么意思?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当像hidden属性这样的属性是布尔属性时,是什么意思?有人可以用外行人的话来解释这个吗?

解决方法

2.5.2 Boolean attributes

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.

If the attribute is present,its value must either be the empty string
or a value that is an ASCII case-insensitive match for the attribute’s
canonical name,with no leading or trailing whitespace.

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

猜你在找的HTML5相关文章