HTML5:禁止结束标记的规范在哪里? [英] HTML5: Where is the spec for which end tags are forbidden?

查看:255
本文介绍了HTML5:禁止结束标记的规范在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML 4.01中,某些结束标记为 禁止 ,这意味着它无法使用有效标记,例如:

In HTML 4.01 certain end tags are forbidden, that means it in not valid markup to have them, e.g.:

Invalid                     Valid
===================         =================
<BR/>                       <BR>
<BR></BR>      

<IMG src="..."/>            <IMG src="...">
<IMG ...></IMG>

<INPUT ... />               <INPUT ...>
<INPUT ...></INPUT>

在HTML 4.01规范中,结束标记的指示是可选 forbidden 元素索引:

In the HTML 4.01 specification the indication of an end tag being optional or forbidden is nicely summarized in the index of elements:

Name        Start Tag       End Tag
AREA                        F
BASE                        F
BASEFONT                    F
BODY        O               O
BR                          F
COL                         F
COLGROUP                    O
DD                          O
DT                          O
FRAME                       F
HEAD        O               O
HR                          F
HTML        O               O
IMG                         F
INPUT                       F
ISINDEX                     F
LI                          O
LINK                        F
META                        F
OPTION                      O
P                           O
PARAM                       F
TBODY       O               O
TD                          O
TFOOT                       O
TH                          O
THEAD                       O
TR                          O

HTML 5相当于指示哪些结束标记的位置:

Where is the HTML 5 equivalent of indicating which end tags are:


  • 必需

  • 可选(隐含)

  • 禁止

推荐答案

HTML5规范中可选结束标记的表现方式和方式:

When and how optional end tags should behave, in HTML5 spec:

http://www.w3.org/TR/html5/syntax .html #void-elements


8.1.2元素



Void elements 只有一个开始标记;不得为 void elements 指定结束标记。

8.1.2 Elements

Void elements only have a start tag; end tags must not be specified for void elements.

无效元素

Void Elements


  • 区域

  • base

  • br

  • col

  • command

  • embed

  • hr

  • img

  • 输入

  • keygen

  • link

  • meta

  • param

  • 来源

  • 追踪

  • wbr

  • area
  • base
  • br
  • col
  • command
  • embed
  • hr
  • img
  • input
  • keygen
  • link
  • meta
  • param
  • source
  • track
  • wbr

更简洁的表格:

Element Type    Start Tag  End Tag
=============== =========  =========
Normal          -          O (some)
   html         O*         O*
   head         O*         O*
   body         -          O*
   li           -          O*
   dt           -          O*
   dd           -          O*
   p            -          O*
   rt           -          O*       
   rp           -          O*
   optgroup     -          O*
   option       -          O*
   colgroup     O*         O*
   thead        -          O*
   tbody        -          O*
   tfoot        -          O*
   tr           -          O*
   td           -          O*
   th           -          O*
   otherwise    -          -
Raw text        -          -
   script
   style
RCDATA          -          -
   textarea
   title
Void            -          F
   area
   base
   br
   col
   command
   embed
   hr
   img
   input
   keygen       
   link
   meta
   param
   source
   track
   wbr
Foreign         -          -          
   MathML
   SVG

这篇关于HTML5:禁止结束标记的规范在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆