Mad*_*r24 5 html html5 asp.net-mvc-4
我一直在网上闲逛,但我似乎无法找到明确的答案.鉴于下面的HTML5结构,我应该在我的旁边元素中使用h2或h3作为内容标题吗?
我知道可以使用多个h1,只要它们在section和/或article元素中.但我不确定在我的旁边应该做些什么?我想我应该远离多个h1,但我不确定h2和h3.
谢谢!
<!DOCTYPE html>
<html>
<head>
<title>Heading Tags</title>
</head>
<body>
<section>
<header>
<h1>Main Section</h1>
</header>
<article>
<h1>Article Title 1</h1>
<div>Some Content Here</div>
</article>
<article>
<h1>Article Title 2</h1>
<div>Some Content Here</div>
</article>
<article>
<h1>Article Title 3</h1>
<div>Some Content Here</div>
</article>
</section>
<aside>
<header>
<h1>Side Bar Heading</h1>
</header>
<div>
<h2>Side Content Title 1</h2>
<div>Some Content Here</div>
</div>
<div>
<h2>Side Content Title 2</h2>
<div>Some Content Here</div>
</div>
<div>
<h2>Side Content Title 3</h2>
<div>Some Content Here</div>
</div>
</aside>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
你真的不应该<h1>在一个页面上使用多个 s 。标签h主要用于规定文档结构。Web内容可访问性指南 (WCAG) 2.0 标准h1显示了标签应为页面添加标题的示例。大多数州(例如伊利诺伊州)都有自己的无障碍标准大纲。伊利诺伊州”在具体概述中指出,一页上只能有一个h1标签,并且其内容与该<title>标签相似。虽然这一点可能会被争论,但仅使用一个h1标签并让其他 5 层正确嵌套是有意义的。
事实上,常识在构建其他h标签时发挥着重要作用。想象一下,当您完成后,以“大纲模式”查看您的网站。是否有意义?
例如,假设您希望网站的轮廓如下所示:
Page Title
Content
- Article
- Sub-article
- Article
Sidebar
- Weather
- Local News
Run Code Online (Sandbox Code Playgroud)
那么你的标题标签应该是这样工作的:
<header>
<h1>My News Website</h1>
<nav></nav>
</header>
<section>
<article>
<h2>Article Title</h2>
<p>Blah Blah Blah.</p>
<h3>Sub-heading in Article</h3>
<p>More blah blah blah.</p>
</article>
<article>
<h2>Article Title</h2>
<p>Blah Blah Blah.</p>
</article>
</section>
<aside>
<h2>Weather</h2>
<p>Weather information.</p>
<h2>Local News</h2>
<ul>
<li>News Item</li>
<li>News Item</li>
</ul>
</aside>
Run Code Online (Sandbox Code Playgroud)
只要您想要的同一级别的内容共享相同的标题编号,那么您就走在正确的轨道上。与标题相关且在上下文中有意义的位于该标题“下方”的内容应将标题编号增加 1。
最后,您可以使用 HTLM 5 大纲向您显示已完成站点的大纲。在这里查看: http: //gsnedders.html5.org/outliner/