Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

whether it is better to use <nav> with <li> <a>, or just <nav> <a>? [closed]

Tags:

html

css

web

<nav>
  <a href="#">Home</a>
  <a href="#">Kontakt</a>
  <a href="#">Jovan</a>
</nav>

or

<nav>
 <ul>
  <li> <a href="#">Home</a> </li>
 </ul>
</nav>

Which is better? When the only nav and <a> or latter. In the first should not be placed in the CSS <inline>

like image 484
jovan922 Avatar asked Feb 16 '23 18:02

jovan922


1 Answers

Accoridng to the W3 spec on <nav>, any kind of flow content is acceptable. And, not that it's of great importance, but both W3 & MDN demonstrating its use using an <ul> (and, for what it's worth, W3 even includes a heading above the <ul> to title the section).

Personally, I think a <ul> describes multiple links better than just solo <a>s, but it's really up to how you want to do it. <ul> also lends itself more semantically to multiple links than simply floating anchors.

like image 100
Brad Christie Avatar answered Mar 10 '23 12:03

Brad Christie