Nesting Requirements
It has always been a rule in HTML that elements should be properly nested within one another. The closing tag of a contained element should always appear before the closing tag of the element that contains it. In XHTML, this rule is strictly enforced. So be sure that your elements are nested correctly, like this:
<p>I can <em>fly!</em></p>
and not overlapping like this:
<p>I can <em>fly!</p></em>
In addition, XHTML enforces other nesting restrictions that have always been a part of the HTML specification. The XHTML DTD includes a special “Content Models for Exclusions” note that reinforces the following:
An
a
element cannot contain anothera
element.The
pre
element cannot containimg
,object
,applet
,big
,small
,sub
,sup
,font
, orbasefont
.The
form
element may not contain otherform
elements.A
button
element cannot containa
,form
,input
,select
,textarea
,label
,button
,iframe
, orisindex
.The
label
element cannot contain otherlabel
elements.
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.