gpt4 book ai didi

html - 将选定和相关属性添加到输入的正确方法是什么?

转载 作者:行者123 更新时间:2023-11-27 22:50:32 25 4
gpt4 key购买 nike

添加 selected 的正确方法(符合标准)是什么? , disabled以及与 <input> 类似的属性HTML 中的元素?

我见过:

<input type="text" disabled>

<input type="text" disabled="disabled">

<input type="text" disabled="yes">

据我所知,无论属性的值是多少,它们都有效。
执行此操作的正确方法是什么?

最佳答案

disabled 是一个 bool 属性。

disabled="disabled" 是正确的形式; disabled 是 HTML 中允许的简写形式。

来自 On SGML and HTML:

Boolean attributes may legally take a single value: the name of the attribute itself (e.g., selected="selected").

In HTML, boolean attributes may appear in minimized form -- the attribute's value appears alone in the element's start tag. Thus, selected may be set by writing:

<OPTION selected>

instead of:

<OPTION selected="selected"> 

Authors should be aware that many useragents only recognize the minimizedform of boolean attributes and not thefull form.

关于html - 将选定和相关属性添加到输入的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3894518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com