Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does <li> always need to be nested between <ul> and <ol>? not <nav>

Tags:

html

I know this question has been asked in various ways specifically with 'nav'

But I keep coming across web pages where 'li' is a child of 'section' or 'article' with no preceding 'ul or 'ol' parent elements. This is usually done in paragraphs. Is this a "correct" method? If so what other elements is it acceptable to omit the 'ol' and 'ul'.

'section' 'li' lorem epsom carpe julgulerum '/li'

( I know "correct" can be debatable especially when taking screen readers into account)

Thank you.

like image 402
SheaFace Avatar asked Nov 16 '25 09:11

SheaFace


1 Answers

According to the Mozilla Developer Network page:

The HTML <li> element is used to represent an item in a list. It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>).

So yes, you need to nest any <li> element inside a list or menu. However a <li> element may contain nearly every other element inside. And also yes, an <article> or a <section> may be contained inside a <li>.

like image 158
KittMedia Avatar answered Nov 17 '25 23:11

KittMedia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!