Home > Web Front-end > CSS Tutorial > Is Using a Div as a Direct Child of a UL Element Valid HTML?

Is Using a Div as a Direct Child of a UL Element Valid HTML?

Mary-Kate Olsen
Release: 2024-12-11 18:49:15
Original
839 people have browsed it

Is Using a Div as a Direct Child of a UL Element Valid HTML?

Can I Use Div as a Direct Child of UL?

While browsers may render the following code without issue:

<ul>
   <div>
   </div>
</ul>
Copy after login

the HTML specification dictates that the only valid child element of ul is li.

HTML 4:

<ELEMENT UL - - (LI)+                 -- unordered list -->
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template