The Little Guy Posted December 10, 2009 Share Posted December 10, 2009 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? Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 10, 2009 Share Posted December 10, 2009 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 Quote Link to comment Share on other sites More sharing options...
haku Posted December 10, 2009 Share Posted December 10, 2009 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. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted December 10, 2009 Author Share Posted December 10, 2009 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. Quote Link to comment Share on other sites More sharing options...
haku Posted December 11, 2009 Share Posted December 11, 2009 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.