Reputation: 5131
I'm new to this "semantic tagging". But I don't know if this is correct. In short, I don't know when to use the section vs the nav tags in this case. Should it be one or the other, none at all, or exactly as I have it? I'm speaking of the section with id = sidebar.
<body>
<div class="page">
<header>
<table id="formHeader" style="width:100%;text-align:center;">
<tr>
<td></td>
</tr>
</table>
<nav>
<ul id="menu">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
</ul>
</nav>
</header>
<section id="sidebar">
@*<nav>*@
Go To...
<ul>
<li>First Move to Moon</li>
<li>First Move to Moon</li>
</ul>
@*</nav>*@
</section>
<section id="main">
@RenderBody()
</section>
<footer>
</footer>
</div>
</body>
Upvotes: 0
Views: 6015
Reputation: 96587
You need to understand two things:
section
, article
, aside
, nav
) creates an entry in the document outline (play around with an outliner, for example gsnedders HTML5 Outliner).nav
belongs to its nearest parent sectioning content element, or the nearest parent sectioning root (like body
).So your example would create the following outline:
1. (no heading) → body
1.1 (no heading) → nav
1.2 (no heading) → section (#sidebar)
1.2.1 (no heading) → nav
1.3. (no heading) → section (#main)
The first nav
would be the navigation for the whole page (or the site navigation), as it belongs to body
.
The second nav
would be the navigation for the sidebar (!).
If this applies to your content, your example is fine. But it probably would only make sense if the sidebar contains other content in addition, otherwise there would be no reason to have a navigation in the first place. If you can’t find a heading (it doesn’t matter if you’d actually use it) for the parent section
, than there is likely something wrong.
Without seeing your actual content, no-one can answer if your structure is correct. What is the nav
in the sidebar used for?
nav
should be a child of this main content.section
(or any other sectioning element), so that it belongs to body
.Upvotes: 6
Reputation: 11
If its a major navigational entity - then the nav tag is the thing to use. My humble opinion is that if you need to put nav elements inside section tags then its not nav-worthy. Not a major navigation.
The code:
<section id="sidebar">
<nav>
Go To...
<ul>
<li>First Move to Moon</li>
<li>First Move to Moon</li>
</ul>
</nav>
</section>
....could perhaps call for an aside tag instead of the section.
Upvotes: 1
Reputation: 4652
I don't know special rules for positioning such tag inside or outside section tag, but I truly believe, that main purpose of semantic markup is seo, and that's why wherever you place this tag today's search engines of Google and others are smart enough to find it.
Upvotes: -1