HTML5之前
缺点:不利于SEO搜索引擎对页面内容的抓取;文档结构定义不明确
HTML5之后
优点:文档结构清晰;对搜索引擎友好
类型 | 取值 |
---|---|
分类 | Sectioning root |
元素上下文 | html元素里的第二个元素 |
内容模型 | 流内容Flow content |
属性 |
全局属性 onafterprint、onhashchange、onmessage、 ononline、onpageshow、onstorage等行为属性 |
<!DOCTYPE HTML>
<html>
<head>
<title>Online or offline?</title>
<script>
function update(online) {
document.getElementById('status').textContent = online ? 'Online' : 'Offline';
}
</script>
</head>
<body ononline="update(true)"
onoffline="update(false)"
onload="update(navigator.onLine)">
<p>You are: <span id="status">(Unknown)</span></p>
</body>
</html>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容,但是不能使header、footer和main三个标签。 |
属性 | 全局属性 |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>网页标题</title>
</head>
<body>
<header>
<h1>Little Green Guys With Guns</h1>
<nav>
<ul>
<li><a href="/games">Games</a>
<li><a href="/forum">Forum</a>
<li><a href="/download">Download</a>
</ul>
</nav>
<h2>Important News</h2>
<p>To play today's games you will need to update your client.</p>
<h2>Games</h2>
</header>
<p>You have three active games:</p>
</body>
</html>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容,但是不能使header、footer和main三个标签。 |
属性 | 全局属性 |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>网页标题</title>
</head>
<body>
<header>some content</header>
<main>some content</main>
<footer>
<nav>
<p>
<a href="/credits.html">Credits</a> —
<a href="/tos.html">Terms of Service</a> —
<a href="/index.html">Blog Index</a>
</p>
</nav>
<p>Copyright © 2009 Gordon Freeman</p>
</footer>
</body>
</html>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 节点内容-Sectioning content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容,但是不能使用main元素 |
属性 | 全局属性 |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>网页标题</title>
</head>
<body>
<header>some content</header>
<main>some content</main>
<footer>
<nav>
<p>
<a href="/credits.html">Credits</a> —
<a href="/tos.html">Terms of Service</a> —
<a href="/index.html">Blog Index</a>
</p>
</nav>
<p>Copyright © 2009 Gordon Freeman</p>
</footer>
</body>
</html>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 节点内容-Sectioning content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容,但是不能使用main元素 |
属性 | 全局属性 |
<header>
<h1>My wonderful blog</h1>
<p>My tagline</p>
</header>
<aside>
<nav>
<h1>My blogroll</h1>
<ul><li><a href="http://blog.example.com/">Example Blog</a></ul>
</nav>
<nav>other nav</nav>
</aside>
<aside>other aside</aside>
<article>
<h1>My last post</h1>
<p>This is my last post.</p>
<footer><p><a href="/last-post" rel=bookmark>Permalink</a></footer>
</article>
<article>other article</article>
<footer>
<nav>
<a href="/archives">Archives</a> —
<a href="/about">About me</a> —
<a href="/copyright">Copyright</a>
</nav>
</footer>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 节点内容-Sectioning content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容 |
属性 | 全局属性 |
<article itemscope itemtype="http://schema.org/BlogPosting">
<header>
<h1 itemprop="headline">The Very First Rule of Life</h1>
<p>
<time itemprop="datePublished" datetime="2009-10-09">3 days ago</time>
</p>
<link itemprop="url" href="?comments=0">
</header>
<p>If there's a microphone anywhere near you, assume it's hot and sending whatever you're saying to the world. Seriously.</p>
<p>...</p>
<footer>
<a itemprop="discussionUrl" href="?comments=1">Show comments...</a>
</footer>
</article>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 节点内容-Sectioning content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容 |
属性 | 全局属性 |
<article class="book">
<header>
<h2>My Book</h2>
<p>A sample with not much content</p>
<p><small>Published by Dummy Publicorp Ltd.</small></p>
</header>
<section class="chapter">
<h3>My First Chapter</h3>
<p>This is the first of my chapters. It doesn't say much.</p>
<p>But it has two paragraphs!</p>
</section>
<section class="chapter">
<h3>It Continutes: The Second Chapter</h3>
<p>Bla dee bla, dee bla dee bla. Boom.</p>
</section>
<section class="appendix">
<h3>Appendix A: Overview of Examples</h3>
<p>These are demonstrations.</p>
</section>
<footer>footer content</footer>
</article>
类型 | 取值 |
---|---|
分类 |
流内容-Flow content 可感知内容-Palpable content |
元素上下文 | 需要流内容的地方 |
内容模型 | 流内容,但是不能使header、footer、section、address等节点元素 |
属性 | 全局属性 |
<address>
<a href="../People/Raggett/">Dave Raggett</a>,
<a href="../People/Arnaud/">Arnaud Le Hors</a>,
contact persons for the <a href="Activity">W3C HTML Activity</a>
</address>
Dave Raggett,
Arnaud Le Hors,
contact persons for the W3C HTML Activity