Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valid lists inside lists - ul inside ul

I need lists inside lists.

What's the most valid way?

<ul>
  <li>
      <ul>
          <li><h2>title</h2></li>
          <li>element</li>
          <li>element</li>
      </ul>
  </li>
  <li>
      <ul>
          <li><h2>title</h2></li>
          <li>element</li>
          <li>element</li>
      </ul>
  </li>

Would that be valid? And semantic?

like image 753
Toni Michel Caubet Avatar asked Aug 11 '11 16:08

Toni Michel Caubet


People also ask

Can you have a UL within a UL?

A nested list is a list inside another list. You can create a nested unordered list, or a nested ordered list, or even an ordered list nested inside an unordered one. Remember that the only direct child of the ul tag is li .

What elements can go inside a UL?

The only legal element inside ul is li.

Can nested list contain both ordered and unordered list in it?

Lists may also be nested and different list types may be used together, as in the following example, which is a definition list that contains an unordered list (the ingredients) and an ordered list (the procedure):

How do I make a list inside a list in HTML?

To create a nested unordered list, simply add the second unordered list below a list item in the first unordered list. This second list should also contain a parent <ul> element and child <li> elements. You must include the closing </ul> tag or the browser will render all the following list items as nested.


1 Answers

VALID, except your second <h2> needs to be in a <li>. You can nest them as much as you want.

like image 72
Bob Fincheimer Avatar answered Sep 28 '22 17:09

Bob Fincheimer