razones técnicas a utilizar en barras de navegación. ¿Hay alguna?
-
12-10-2019 - |
Pregunta
¿Hay razones técnicas (CSS relaciona / jQuery) por qué utilizar la etiqueta <ul>
de barras de navegación, en lugar de usar las etiquetas a
?
<nav>
<ul class="links">
<li><a href="/">Home page</a></li>
<li><a href="/about">About page</a></li>
</ul>
</nav>
vs
<nav>
<a href="/">Home page</a>
<a href="/about">About page</a>
</nav>
Solución
- It's, arguably, 'more semantic': those links probably are a list
- Without the
nav
element, (i.e. in HTML5), theul
often provides a useful container for styling
Otros consejos
Unlike XML, you cannot make-up tags in HTML. Sure, will probably work but it's invalid mark-up.
Lists usually provide a nice way to mark things up that make sense. Structure, it usually makes sense (you typically have a list of items in your navigation, no?). Definition lists can lend themselves to some forms of navigation but lists usually make the most sense.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow