dom – 应该如何编写布尔属性?

dom – 应该如何编写布尔属性?,第1张

概述参见英文答案 > What values can appear in the “selected” attribute of the “option” tag?                                    8个 我一直在阅读一些关于HTML,XHTML等的文章.在大多数文章中(即 My preferred syntax style)说布尔属性应该写成没有任何值,如下所示: 参见英文答案 > What values can appear in the “selected” attribute of the “option” tag?                                    8个
我一直在阅读一些关于HTML,xhtml等的文章.在大多数文章中(即 My preferred syntax style)说布尔属性应该写成没有任何值,如下所示:

<input type="text" required>

他们甚至说使用这样的属性是错误的:

<input type="text" required="required">

其中一些文章链接W3,其中说:

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.

但在示例中显示如下:

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>

那么,应该如何编写布尔属性?根据您的经验,哪些选项是跨浏览器而哪些不是?

解决方法 没有值的属性在HTML中有效,但在xhtml中无效,因为它不允许在XML中使用.也许这就是你的困惑所在.那么,哪一个有效取决于您的文档的DOCTYPE. 总结

以上是内存溢出为你收集整理的dom – 应该如何编写布尔属性?全部内容,希望文章能够帮你解决dom – 应该如何编写布尔属性?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1067127.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存