HTML allows to omit certain start and/or end tags:
Some HTML element types allow authors to omit end tags (e.g., the P
and LI
element types). A few element types also allow the start tags to be omitted; for example, HEAD
and BODY
. The HTML DTD indicates for each element type whether the start tag and end tag are required.
If you examine a document type definition like the one of HTML 4.01, the elements are declared with the element declarations <!ELEMENT … >
. And within such an element declarations, two characters specify whether the start or end tag of an element can be omitted. See the definition of P
for example:
<!ELEMENT P - O (%inline;)* -- paragraph -->
Here the -
after the element name P
denotes that the start tag is required and the O
denotes that the end tag may be omitted. Another example, the HEAD
element:
<!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head -->
Here the two O
specify that both the start and end tag can be omitted.
Omitting both tags on elements is only possible as such elements are implicit in their context. In case of HEAD
, the content model of the parent element HTML
is specified as follows:
<!ELEMENT HTML O O (%html.content;) -- document root element -->
Where the parameter entity html.content is defined as follows:
<!ENTITY % html.content "HEAD, BODY">
That means the content model of HTML
is implicitly defined as HEAD
followed by BODY
.
You can take a look at the index of HTML 4.01 elements to see what tags of what elements can be omitted.