views:

681

answers:

3

I'm working on developing a Web 2.0 site, and I've been looking at how sites deal with menus and nav-bars. Many sites (like twitter) use UL's whereas sites such as stackoverflow use div's that are ID's containing links.

Is there an advantage to not using UL's other than it eliminates some IE bugs?

is there an advantage to using UL's?

Thanks!

+8  A: 

It depends on how you look at it, UL stands for unordered list. Putting things in a UL element is a semantic way of saying the elements children ( <li> ) are list items and therefore a logical group. Which gives the chunk of html more structure/meaning than just a bunch of div tags.

Is a menu a list? I think so. So if you can for something like this prefer the ul.

ul's can be more difficult to style with css, especially when the menu is horizontal.

Chad Grant
I agree with everything except the last sentence. They are really easy to style, almost exactly like a div in fact as you can set the li element to display: block, at which point you have yourself something a lot like a div.
Sohnee
notice the word of *can* in that sentence, and referring to horizontal. Once you know how its not so bad ... but it does take more css and knowledge to style a ul horizontally, not display ticks, etc...
Chad Grant
+6  A: 

UL's are more friendly to screen-readers, and are a way to force you to keep the menu clean of other html. The li-tags can essentially be handled like divs, if you want that.

So basically the difference is that the ul-tag is a bit more specialized, but can deliver essentially the same thing as divs could.

Jacob Hansson
+4  A: 

I personally use ul/li for all of my menu needs as it makes it clear to even an unstyled browser (Links for example) that it is a menu of some sort and that they are various links that lead to different parts on a website.

Not only that, but the markup is remarkably easy and allows for very interesting things to be done using ul, li, and a to make awesome menu's with CSS with various options, CSS sprite backgrounds.

Using divs makes this possible as well, but makes the intent less clear. With a browser that does proper CSS layout you won't notice a difference and the only one that will know is you and the user that does a view-source.

It may make a difference if you need to parse the dom using javascript, it may not...

X-Istence
Thanks, I suppose clear intent is important when working with development teams, and with what Sohnee said about display:block, I think I can accomplish everything I need.
Ryan Rohrer
Also, if your site requires (or ever will require) 508 compliance, the hierarchical structure of multiple nested ul, li will help for Textreader navigation.
Jay Stevens