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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.