Reputation: 6109
Why do almost everybody I see use this kind of structure when creating some sort of navigation
<ul>
<li><a href="/link1">link1</a></li>
<li><a href="/link2">link2</a></li>
<li><a href="/link3">link3</a></li>
</ul>
instead of this?
<div>
<a href="/link1">link1</a>
<a href="/link2">link2</a>
<a href="/link3">link3</a>
</div>
What are the advantages of the first one compared to the last one? Since so many are doing it this way.
Upvotes: 5
Views: 163
Reputation: 56773
It's about semantic use of html. You have a list of links, so you use the appropriate html element which in this case is either a <ul>
(if order doesn't matter semantically) or an orderer list <ol>
(if order is meaningful, for example if you have a month navigation listing January to December).
https://en.wikipedia.org/wiki/Semantic_HTML
http://www.html5rocks.com/en/features/semantics
Upvotes: 3
Reputation: 121
Navigation is a actually a list, that's why. It's a game of semantics. But I personally prefer to use and navigation (when I'm designing from scratch).
Upvotes: 0
Reputation: 944054
In short, because the content is a list of links, so we write markup that reflects that.
It gives us more options for styling the links (since the additional markup gives us more elements to play with), and it lets us tell them apart without access to visual styling.
Upvotes: 3