From my perspective, the optimal solution would be the first one as your menu functions as a navigation tool, requires less code, and is just as beneficial for SEO as the second option.
<nav>
<a href="#">Home</a>
<a href="#">Contact</a>
<a href="#">About</a>
</nav>
If you decide to include additional elements within your nav
, such as ul
, ol
, h1
, or even table
, it's important to maintain semantic correctness. For instance, if your menu resembles a list, using ul
is appropriate. However, if you simply wish to enhance styling capabilities, consider utilizing div
and/or span
.
Update
Following some discussions in the comments section: In most scenarios, a menu can be likened to a list, hence opting for the ul
approach is highly recommended. By incorporating ul
, screen readers are better equipped to navigate the menu, as suggested by Steve