I couldn't find a clear answer/explanation to this question so far.
This seems uncontroversial from an accessibility perspective:
Example A:
<header>
<!-- Other stuff like a logo or other buttons -->
<nav>
<button>Menu</button>
<ul>
<li><a href="">Page 1</a></li>
<li><a href="">Page 2</a></li>
<li><a href="">Page 3</a></li>
</ul>
</nav>
</header>
However from a UI design perspective, this may be limiting. It would be liberating to have a markup like this:
Example B:
<header>
<!-- Other stuff like a logo or other buttons -->
<button>Menu</button>
<nav>
<ul>
<li><a href="">Page 1</a></li>
<li><a href="">Page 2</a></li>
<li><a href="">Page 3</a></li>
</ul>
</nav>
</header>
In either case, if the navigation was closed, the nav
element would not have to be hidden, it would be enough to hide the ul
element using display none.
Although in example B, hiding the nav
element (i.e. the entire navigation) might be better from a UX perspective, since a closed navigation without an open/close button as a child might be confusing, but I am not sure.