Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nesting <UL> lists

Status
Not open for further replies.

rjoubert

Programmer
Oct 2, 2003
1,843
US
Which HTML syntax is correct when nesting unordered lists?

<UL>
<LI>Top Level List Item[red]</LI>[/red]
<UL>
<LI>Second level</LI>
</UL>
</UL>

OR...

<UL>
<LI>Top Level List Item
<UL>
<LI>Second level</LI>
</UL>
[red]</LI>[/red]
</UL>

Both seem to yield the same results, but I'm just wondering if one is more accepted.
 
The second is valid, the first is not. Because <ul> is not acceptable child of another <ul> but it can be a child of a <li> element. User agents usually render them the same because they "guess" you closed the li element at the wrong place.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Only the second method validates...

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Holy cow. I must be slow today. [blush]

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Greg said:
I must be slow today.

I don't know...you managed to get both of your replies posted in the same minute that I posted my last one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top