当属性是布尔属性时,它在HTML 5中意味着什么? [英] What does it mean in HTML 5 when an attribute is a boolean attribute?

查看:504
本文介绍了当属性是布尔属性时,它在HTML 5中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当隐藏属性等属性是布尔属性时,这意味着什么?有人可以用外行人的话来解释这个吗?

What does it mean when an attribute like the hidden attribute is a boolean attribute? Can someone explain this in layman's terms?

推荐答案


2.5.2布尔属性

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.

如果属性存在,它的值必须是空字符串
,或者是属性的
规范名称的ASCII区分大小写匹配的值,不带前导或尾随空格。

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.

布尔属性不允许使用值true和false。
要表示错误值,必须省略该属性

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

这篇关于当属性是布尔属性时,它在HTML 5中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆