是autofocus ="autofocus"吗?还是自动对焦? [英] is it autofocus="autofocus" or autofocus?
问题描述
我似乎想起了以前版本的HTML(在HTML5之前)中的大多数(也许是所有)属性,它们要求属性具有诸如readonly="readonly"
之类的值.
I seem to recall most (maybe all) attributes in previously versions of HTML (before HTML5) required attributes to have values, like readonly="readonly"
.
HTML5和autofocus
属性是否正确?
Is this true for HTML5 and the autofocus
attribute?
推荐答案
在HTML中,可以根据需要使用带或不带值的布尔属性.
对于W3C,像自动对焦这样的布尔值可以这样写:autofocus
或autofocus="autofocus"
或autofocus=""
.
In HTML, you use boolean attributes with or without values as you like.
A boolean, for W3C, like autofocus can be written like that autofocus
or autofocus="autofocus"
or also autofocus=""
.
如果您不希望自动对焦,请不要编写它.
If you don't want autofocus just don't write it.
我认为您很困惑,因为XHTML需要所有属性的值:attributes="values"
.
I think you are confused because XHTML requires values for all attributes: attributes="values"
.
以下是有关在HTML中使用布尔属性的一些信息: http://www.whatwg .org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#boolean-attribute
Here is some information about boolean attribute use in HTML: http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#boolean-attribute
这篇关于是autofocus ="autofocus"吗?还是自动对焦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!