Jump to content

Nested Lists


The Little Guy

Recommended Posts

What is the proper way to nest list elements?

 

According to the w3 list documentation the following method is depreciated:

<ol>
     <li>Main Item 1
          <ul>
               <li>Sub Item 1</li>
               <li>Sub Item 2</li>
          </ul>
     </li>
     <li>Main Item 2
          <ul>
               <li>Sub Item 1</li>
               <li>Sub Item 2</li>
          </ul>
     </li>
</ol>

 

If that is depreciated, then what is the correct way?

Link to comment
https://forums.phpfreaks.com/topic/184613-nested-lists/
Share on other sites

The example you gave is different from the one on the W3C site. What is deprecated is having nested lists that aren't contained within a list tag. Ex

 

<ul>
  <li>some text
    <ol>
      <li>some other text
    </ol>
  <li>and finally the last text
</ul>

 

This is deprecated. The proper format is like this:

<ul>
  <li>some text
    <ol>
      <li>some other text
    </ol>
  <li>and finally the last text
</ul>

 

Notice that the li tag that contains the nested ol has a closing tag, thereby fully enclosing the ol.

Link to comment
https://forums.phpfreaks.com/topic/184613-nested-lists/#findComment-974599
Share on other sites

The example you gave is different from the one on the W3C site. What is deprecated is having nested lists that aren't contained within a list tag. Ex

 

<ul>
  <li>some text
    <ol>
      <li>some other text
    </ol>
  <li>and finally the last text
</ul>

 

This is deprecated. The proper format is like this:

<ul>
  <li>some text
    <ol>
      <li>some other text
    </ol>
  <li>and finally the last text
</ul>

 

Notice that the li tag that contains the nested ol has a closing tag, thereby fully enclosing the ol.

 

Is it just me, or did you forget the closing li? :)

So the way I am doing it is correct I presume.

 

is there any specific reason why you want to nest list elements.

 

can you show a structure print screen about what u trying to create.

 

there can be other alternatives also.

 

vineet

 

Well, I was making a list, and I needed sub elements to main elements...

Anyway, I found a way I like better, it is the definition list.

Link to comment
https://forums.phpfreaks.com/topic/184613-nested-lists/#findComment-974994
Share on other sites

I don't know why I wrote the same list two times. I was having a stupid moment I guess. Yes, the way you were doing it is correct. It should look like this:

 

<ul>
  <li>some text
    <ol>
      <li>some other text</li>
    </ol>
  </li>
  <li>and finally the last text</li>
</ul>

Link to comment
https://forums.phpfreaks.com/topic/184613-nested-lists/#findComment-975144
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.