Skip to content Skip to sidebar Skip to footer

Can You Put Li Elements Inside A Div

Ok, so I have looked around w3c and blogs and have not found an argument as to why I cannot do the following html:
  • 1

Solution 1:

No. This is invalid HTML.

Permittend content: zero or more <li> elements, eventually mixed with <ol> and <ul> elements.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ul

Solution 2:

If you search for "HTML Validator" you can quickly run some code through one to see if it is valid or not. Div tags aren't valid as first level child elements of a ul tag. Whatever you are trying to achieve can be accomplished by styling the li tags with CSS.

Post a Comment for "Can You Put Li Elements Inside A Div"