Can I Use Div as a Direct Child of UL?
While browsers may render the following code without issue:
<ul> <div> </div> </ul>
the HTML specification dictates that the only valid child element of ul is li.
HTML 4:
<ELEMENT UL - - (LI)+ -- unordered list -->
HTML 5:
Content model:
Zero or more li elements.
Therefore, using div as a direct child of ul is not allowed according to the HTML specifications. This is in contrast to the information provided in the linked CSS-Tricks forum discussion.
The above is the detailed content of Is Using a Div as a Direct Child of a UL Element Valid HTML?. For more information, please follow other related articles on the PHP Chinese website!