Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5: Where is the spec for which end tags are forbidden?

Tags:

html

w3c

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>

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

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

  • required
  • optional (implicit)
  • forbidden
like image 947
Ian Boyd Avatar asked Feb 24 '12 16:02

Ian Boyd


People also ask

Which tag in HTML 5 does not have an end tag?

Empty elements do not have an end tag!

Which HTML5 tags are not supported?

Some attributes from HTML4 are no longer allowed in HTML5 at all and they have been removed completely. img and iframe. caption, iframe, img, input, object, legend, table, hr, div, h1, h2, h3, h4, h5, h6, p, col, colgroup, tbody, td, tfoot, th, thead and tr. table, tr, td, th and body.


1 Answers

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

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

8.1.2 Elements

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

Void Elements

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

A more concise form:

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
like image 74
Mikko Ohtamaa Avatar answered Sep 22 '22 11:09

Mikko Ohtamaa