Can the <li> element contain content other than text?


#1

Question

Can the <li> element contain content other than text? For example, can we have lists of videos or songs or hyperlinks or some combination of all three?

Answer

Yes we can! The <li> element can contain any element which is valid within the <body> tag. This means that we can have lists of videos, images, songs, hyperlinks, or any combination thereof. In fact, we can even have lists of lists!


FAQ: Learn HTML Elements - Intro to HTML - Ordered Lists
#4

Wow! I didn’t know the li element is so versatile.


#5

yes, MDN always has good documentation so for example about <li>:

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

we can see: permitted content flow content, then you can see what tags are flow content. Which are a lot


#6

You can create an unordered list containing an ordered referencing an image of an ordered list containing an unordered list.