Why I Don’t Like Lists in Nav Elements

05-25-11 Ryan Buttrey

Last week in the Sparkbox office, the question came up whether or not it is necessary to use lists inside the HTML5 nav element.

Last week in the Sparkbox office, the question came up whether or not it is necessary to use lists inside the HTML5 nav element. I say no, it’s not. Here’s why.

Let’s start off by looking back to before HTML5 existed. When structuring the markup for the main navigation, it might look something like this:


Fair enough. I think we all pretty much have agreed that is the standard. So when HTML5 came along and added the nav element, naturally markup started looking like this:


That, in itself, is not wrong. And certainly there is a case for that (for example, nested navigation). But, it’s not necessary. To make my point a little clearer, first let’s look at the actual definition of the nav element.

“The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links. Not all groups of links on a page need to be in a nav element only sections that consist of major navigation blocks are appropriate for the nav element. In particular, it is common for footers to have a list of links to various key parts of a site, but the footer element is more appropriate in such cases, and no nav element is necessary for those links.”

The HTML 5 specification

In the past, nav was used to “contain” a list of navigation links. Now the nav element exists and, by definition, groups the links. So the ul is unnecessary.


So Basically…

Is an unordered list necessary? No. Can it be used? Absolutely. Should it be used by default just because that’s how you’ve always done it? Definitely not.

Disagree?

Read Rob Tarr’s thoughts on the same subject and realize I make more sense.