View Full Version : ul vs nested divs

09-05-2010, 05:58 AM

When I create navigation menus, I typically have html markup this way:

<div id="mainMenu">
<div><a href="#">Link 1</a></div>
<div><a href="#">Link 2</a></div>
<div><a href="#">Link 3</a></div>

I found many people use ul instead:

<ul id="mainMenu">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>

Both work after some styling, are there advantages using ul ? I believe it's the more popular way, but to me ul needs more works like hiding the bullets and taking away margins and paddings.


09-05-2010, 09:42 AM
Navigation menu is basically a "list" of of links and thus using a list would be more semantic (http://boagworld.com/technology/semantic-code-what-why-how) than using passive <div> elements, which do not imply anything to the document. If it's a list, then it'll be rendered with some structure by the browser, even if there's no CSS applied.