So, I’ve been collecting CSS menus for some time now (another term is borrowing, another is blatant tearing) to learn from them and potentially reuse some of them in my own projects.
Being an oldschool-style purist, I like the idea of stylized <ul> and <ol> s, and better tab menus and interfaces tend to use this method for accessibility or semantic stability or for any reason. I mostly like this method because it keeps my HTML source nice and clean.
Now, I have actually reorganized my CSS menu collection to fit the “master” markup template, which I extrapolated from the most flexible examples such as CSS Zen Garden. It looks like this:
<div class="menustyle"> <ul> <li class="current"><a href="#" title="Page 1"><span>Home</span></a></li> <li><a href="#" title="Page 2"><span>Toys</span></a></li> <li><a href="#" title="Page 3"><span>About Us</span></a></li> <li><a href="#" title="Page 4"><span>Contact</span></a></li> </ul> </div> <span class="clearit" /><br />
(the "clearit" space at the end is used to set clear:both after the menu they require)
Anyway, I saw variations of this markup on many sites, some with the additional conclusion of <div> , some of which use a different word than current , some add the class current to the <a> tag than <li> , and some leave an internal <span> . Each seems to have its own way of marking up the menu, which is slightly different from the other.
In any case, after I was busy with a lot of menus, the above is what I came up with, but I'm trying to find out if there really is an established best practice for this. At some point, I would like to create a simple CSS menu listing, and it would be nice to get some input on the markup before moving on.
EDIT: The question is not about the Javascript menu. I know that there are excellent menu scripts, and they allow you to have submenus, more advanced animations and hover times, keyboard shortcuts, shadows and everything else. But 90% of the menus do not need these features and use CSS much better for styling and hanging.