DEVFYI - Developer Resource - FYI

Only certain tags may nest inside other tags

XHTML Interview Questions and Answers


(Continued from previous question...)

32. Only certain tags may nest inside other tags

Looking at the dtd for xhtml, the definition of the "ol" element is:

<!ELEMENT ol (li)+>
<!ATTLIST ol
%attrs;
type %OLStyle; #IMPLIED
compact (compact) #IMPLIED
start %Number; #IMPLIED
>

This implies that an order list, "ol", element may not contain paragraph tags or body text, just list items.
<ol>

These are some of my favorite animals:
<li>octopus</li>
<li>shrew</li>
<li>lemur</li>
and my most favorite
<li>meerkats</li>
</ol>

becomes
<p>These are some of my favorite animals:</p>
<ol>
<li>octopus</li>
<li>shrew</li>
<li>lemur</li>
<li>meerkats</li>
</ol>

Other Interview Questions