html - 是自动对焦 ="autofocus"还是自动对焦?

标签 html autofocus

我似乎记得以前版本的 HTML(在 HTML5 之前)中的大多数(也许是全部)属性都要求属性具有值,例如 readonly="readonly"

HTML5 和 autofocus 属性是否如此?

最佳答案

在 HTML 中,您可以根据需要使用带值或不带值的 bool 属性。 一个 bool 值,对于 W3C,像 autofocus 可以这样写 autofocusautofocus="autofocus"autofocus="" .

如果你不想自动对焦就不要写它。

我认为您感到困惑,因为 XHTML 需要所有属性的值:attributes="values" .

这里是一些关于在 HTML 中使用 boolean 属性的信息: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#boolean-attribute

关于html - 是自动对焦 ="autofocus"还是自动对焦?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4445765/

相关文章:

html - 尝试使用 :hover on another pseudo class 更改导航项背景图像

javascript - 在 Chrome 上使用 Javascript 获取打印页面宽度/高度

javascript - react : AutoFocus on Input field inside Modal

javascript - angularjs 中 ng-repeat 的自动对焦

reactjs - if else 根据条件自动对焦

javascript - 如何在类 :before using jquery? 中设置动态高度

html - <ul> 分离不当

html - 向现有 HTML 添加行号

android相机连续对焦(按需)

opencv - 光学成像中像面的位置