It’s more semantically correct to use a list (plus your not stuffing a generic DIV where it’s not needed). A menu is by definition a list of links to various sections of a website, therefore it should be provided as such in a list. If you’re going to code a website, you may as well use the right tool for the right job.
There is no real reason why you shouldn’t but like was mentioned it’s considered slightly more semantic to use LI. Although it’s not really any more an “unordered list” than a paragraph is a list of words (in some cases) it a kind of limitation of current navigation-specific elements. Now, if the links required OL then yes, it is more apt - I am not disagreeing just putting forward a different perspective.
Someone using a browser where your CSS isn’t applied would be unable to tell where one link ends and the other starts as the two run into one another. Visually there might be a slight gap in the underline but for anyone listening there is nothing to divide up the links. At the very least if you are going to have multiple <a> within the one element you need at least one character of actual text in between such as |
Marking up your list as a list is not only more semantic, it also takes care of dividing up the links so that everyone can tell where they start and finish.
@kohoutek - You bring up a good question, “can a list contain just one item (element)”. I’d argue that a list must contain more than one item, unless it isn’t a list.
Coop, I won’t debate coding semantics with you, because I will lose but I will posit that in spoken/written language semantics, a list must contain more than one item to be a list.
[highlight=“Proper English”]Cooper’s grocery list includes: butter, cheese, milk, and bread.
However, in HTML, a list can contain a single item to be functionally, and semantically, correct.
[highlight="HTML 4.01 Strict"]<ul>
<li>an item</li>
</ul>
It validates, it works on the page … I don’t see the downside.
Tell me I’m wrong if you must but, please, explain why.
Yes, it does look ridiculous but if I take a music album comprising two discs; the first disc has 12 songs, the second disc has only one song. Were I to write that in HTML, I would write two lists, the second one containing all but a single item.
If no element can semantically define the intended content, then a neutral element should be used. Since block level elements are sitting before/after, a neutral block level element would encapsulate the one grocery item/album song.
It is absolutely contradictory. But it also means I can create a one-item list, if need be, that won’t make my code or anyone’s browser throw a hairball.
I never said that I think it’s correct because the W3C says so.
When I write a grocery list, even if I just have one item to shop today, it’s still my grocery list. The nature of the item doesn’t change. At least I don’t think it does. It seems logical to me (which means absolutely nothing).
Sorry, I was speaking out of context. When you or I write a list, we write more than one item, because if we go to the store to get just one item, we don’t need to write anything, correct?