首页 > 试题广场 >

以下哪段代码符合HTML5书写规范:

[单选题]
以下哪段代码符合HTML5书写规范:
  • <div id="1">some text</div>
  • <  form
    action="some action" >
    < button >some text< / button >
    < / form >
  • <ul>
    <li>some text
    <li>some text
    <li>some text
    </ul>
  • <type="text" input value="some value" />
A. id为纯数字
B. 使用 button 元素时必须指明 type 属性值
C.如果一个<li>元素之后紧跟另一个<li>元素,或在父元素中没有其他更多内容,则结束标签可以省略
D. input应放最前
编辑于 2019-08-16 14:04:06 回复(11)
选C,html5中可以省略结束标记的元素有

1、dd

2、dt

3、li

4、p

5、optgroup

6、option

7、rt

8、rp

9、thread

10、tfoot

11、tr

12、td

13、th

发表于 2019-08-16 11:59:23 回复(11)

H5 并没有规定 id 不能为数字。以下摘自 H5 规范:

There are no other restrictions on what form an ID can take; in particular, IDs can consist of just digits, start with a digit, start with an underscore, consist of just punctuation, etc.

虽然习惯上我们并不会让 id 为纯数字,但是让 id 为纯数字并不违反 HTML 5 的规范。

至于为什么有 id 不能为纯数字的说法,我个人认为主要是两点:

  1. 来自其他编程语言的习惯。我们一般不会用数字来命名变量,这是违反精神模型的;然而由于前端框架的普及,使用数字作为 id 和 key 的现象非常常见。

  2. 出于兼容性考虑。HTML 4 规范指出,id 必须以字母开头。但正如刚才说的,HTML 5 已经移除了这一限制。

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

编辑于 2020-10-02 18:08:53 回复(2)
B 的问题在于:标签的前括号和标签名之间不能有空格

发表于 2021-10-06 21:05:47 回复(1)
B难道不是因为闭合标签 <和/没有连在一起吗,为什么都说button标签一定要加type?
发表于 2021-02-09 08:09:13 回复(2)
html5中可以省略结束标记的元素有

1、dd

2、dt

3、li

4、p

5、optgroup

6、option

7、rt

8、rp

9、thread

10、tfoot

11、tr

12、td

13、th

发表于 2021-06-19 19:22:32 回复(0)
如果一个<li>元素之后紧跟另一个<li>元素,或在父元素中没有其他更多内容,则结束标签可以省略
发表于 2021-04-23 13:29:50 回复(0)
html5中可以省略结束标记的元素有这些:

1、dd

2、dt

3、li

4、p

5、optgroup

6、option

7、rt

8、rp

9、thread

10、tfoot

11、tr

12、td

13、th

发表于 2019-09-27 22:36:52 回复(0)
看到c答案的li没有缩进非常的恼火😡
发表于 2021-08-08 14:27:26 回复(0)
***题
发表于 2023-02-11 20:53:23 回复(0)
li结束标记还能省略的吗...
发表于 2021-09-11 14:26:31 回复(0)
请始终为 <button> 元素规定 type 属性。不同的浏览器对 <button> 元素的 type 属性使用不同的默认值。</button></button>
发表于 2021-01-04 08:26:46 回复(0)
id的取值必须以字母开头
发表于 2019-11-03 18:00:35 回复(0)
button要指明type
发表于 2020-05-12 22:28:49 回复(0)
A. id为纯数字 B. 使用 button 元素时必须指明 type 属性值 C.如果一个
  • 元素之后紧跟另一个
  • 元素,或在父元素中没有其他更多内容,则结束标签可以省略 D. input应放最前
  • 发表于 2019-11-15 18:11:28 回复(0)
    原来还可以省略元素
    发表于 2023-08-06 14:09:26 回复(0)
    html5中可以省略结束标记的元素有 1、dd 2、dt 3、li 4、p 5、optgroup 6、option 7、rt 8、rp 9、thread 10、tfoot 11、tr 12、td 13、th
    发表于 2023-05-16 15:33:00 回复(0)
    如果一个
  • 元素之后紧跟另一个
  • 元素,或在父元素中没有其他更多内容,则结束标签可以省略
  • 发表于 2022-10-13 11:21:18 回复(0)
    A. id为纯数字 B. 使用 button 元素时必须指明 type 属性值 C.如果一个
  • 元素之后紧跟另一个
  • 元素,或在父元素中没有其他更多内容,则结束标签可以省略 D. input应放最前
  • 发表于 2022-09-21 09:09:30 回复(0)
    id的取值必须以字母开头
    发表于 2022-07-28 10:50:43 回复(0)