html5教程-HTML5的结构和语义――结构(二)

发布时间:2018-12-18 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了html5教程-HTML5的结构和语义――结构(二)脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。
由于缺少结构,即使是形式良好的HTML 页面也比较难以处理。必须分析标题的级别,才能看出各个部分的划分方式。边栏、页脚、页眉、导航条、主内容区和各篇文章都由通用的p 元素来表示。html 5 添加了一些新元素,专门用来标识这些常见的结构:
 
 ·section:这可以是书中的一章或一节,实际上可以是在HTML 4 中有自己的标题的任何东西
 ·header:页面上显示的页眉;与head 元素不一样
 ·footer:页脚;可以显示子邮件中的签名
 ·nav:指向其他页面的一组链接
 ·article:blog、杂志、文章汇编等中的一篇文章
 
  我们来考虑一个典型的bLOG 主页,它的顶部有页眉,底部有页脚,还有几篇文章、一个导航区和一个边栏,见代码1 典型的blog 页面
 
以下是代码片段:[www.xlnv.net]
<html>
<head>
<tITle>;mokka mit Schlag </title>
</head>
<body>
<p id="page">
<p id="header">
<h1><a href="https://www.xlnv.net">Mokka mit Schlag</a></h1>
</p>
<p id="container">
<p id="center" class="column">
<p class="post" id="post-1000572">
<h2><a href=
"/blog/birding/2007/04/23/sPRing-comes-and-goes-in-sussex-county/">
Spring Comes (and Goes) in Sussex County</a></h2>
 
<p class="entry">
<p>Yesterday I joined the brooklyn Bird Club for our
annual trip to Western New Jersey, sPEcifically Hyper
Humus, a relatively recently discovered hot spot. It
started out as a nice winter morning when we arrived
at the site at 7:30 A.M., progressed to Spring around
10:00 A.M., and reached early summer by 10:15. </p>
</p>
</p>
 
 
<p class="post" id="post-1000571">
<h2><a href=
"/blog/birding/2007/04/23/but-does-it-count-for-your-life-list/">
But does it count for your life list?</a></h2>
 
<p class="entry">
<p>Seems you can now go <a
href="https://www.wired.COM/science/discoveries/news/
2007/04/cone_sf">bird watching via the internet</a>. I
haven&#39;t been able to test it out yet (20 user
limit apparently) but this is certainly cool.
Personally, I can't imagine it replacing
actually being out in the field by any small amount.
On the other hand, I've always found it quite
sad to meet senior birders who are no longer able to
hold binoculars steady or get to the park. I can
imagine this might be of some interest to them. At
least one elderly birder did a Big year on TV, after
he could no longer get out so much. This certainly
tops that.</p>
</p>
</p>
 
</p>
 
<p class="navigation">
<p class="alignleft">
<a href="/blog/page/2/">« Previous Entries</a>
</p>
<p class="alignright"></p>
</p>
</p>
 
<p id="right" class="column">
<ul id="sidebar">
<li><h2>Info</h2>
<ul>
<li><a href="/blog/comment-policy/">Comment Policy</a></li>
<li><a href="/blog/todo-list/">Todo List</a></li>
</ul></li>
<li><h2>Archives</h2>
<ul>
<li><a href='/blog/2007/04/'>April 2007</a></li>
<li><a href='/blog/2007/03/'>March 2007</a></li>
<li><a href='/blog/2007/02/'>February 2007</a></li>
<li><a href='/blog/2007/01/'>January 2007</a></li>
</ul>
</li>
</ul>
</p>
<p id="footer">
<p>Copyright 2007 Elliotte Rusty Harold</p>
</p>
</p>
 
</body>
</html>
 
  即使有正确的缩进,这些嵌套的p 仍然让人觉得非常混乱。在HTML 5 中,可以将这些元素替换为语义性的元素,见代码2 用HTML5编写的典型blog页面
 
以下是代码片段:[www.xlnv.net]
<html>
<head>
<title>Mokka mit Schlag </title>
</head>
<body>
<header>
<h1><a href="https://www.elharo.com/blog">Mokka mit Schlag</a></h1>
</header>
<section>
<article>
<h2><a href=
"/blog/birding/2007/04/23/spring-comes-and-goes-in-sussex-county/">
Spring Comes (and Goes) in Sussex County</a></h2>
 
<p>Yesterday I joined the Brooklyn Bird Club for our
annual trip to Western New Jersey, specifically Hyper
Humus, a relatively recently discovered hot spot. It
started out as a nice winter morning when we arrived at
the site at 7:30 A.M., progressed to Spring around 10:00
A.M., and reached early summer by 10:15. </p>
</article>
 
 
<article>
<h2><a href=
"/blog/birding/2007/04/23/but-does-it-count-for-your-life-list/">
But does it count for your life list?</a></h2>
 
<p>Seems you can now go <a
href="https://www.wired.com/science/discoveries/news/
2007/04/cone_sf">bird watching via the Internet</a>. I
haven't been able to test it out yet (20 user
limit apparently) but this is certainly cool.
Personally, I can't imagine it replacing
actually being out in the field by any small amount.
On the other hand, I've always found it quite
sad to meet senior birders who are no longer able to
hold binoculars steady or get to the park. I can
imagine this might be of some interest to them. At
least one elderly birder did a big year on TV, after
he could no longer get out so much. This certainly
tops that.</p>
</article>
<nav>
<a href="/blog/page/2/">« Previous Entries</a>
</nav>
</section>
 
<nav>
<ul>
<li><h2>Info</h2>
<ul>
<li><a href="/blog/comment-policy/">Comment Policy</a></li>
<li><a href="/blog/todo-list/">Todo List</a></li>
</ul></li>
<li><h2>Archives</h2>
<ul>
<li><a href='/blog/2007/04/'>April 2007</a></li>
<li><a href='/blog/2007/03/'>March 2007</a></li>
<li><a href='/blog/2007/02/'>February 2007</a></li>
<li><a href='/blog/2007/01/'>January 2007</a></li>
</ul>
</li>
</ul>
</nav>
<footer>
<p>Copyright 2007 Elliotte Rusty Harold</p>
</footer>
 
</body>
</html>
  现在不再需要p 了。不再需要自己设置class 属性,从标准的元素名就可以推断出各个部分的意义。这对于音频浏览器、手机浏览器和其他非标准浏览器尤其重要
由于缺少结构,即使是形式良好的HTML 页面也比较难以处理。必须分析标题的级别,才能看出各个部分的划分方式。边栏、页脚、页眉、导航条、主内容区和各篇文章都由通用的p 元素来表示。HTML 5 添加了一些新元素,专门用来标识这些常见的结构:
 
 ·section:这可以是书中的一章或一节,实际上可以是在HTML 4 中有自己的标题的任何东西
 ·header:页面上显示的页眉;与head 元素不一样
 ·footer:页脚;可以显示电子邮件中的签名
 ·nav:指向其他页面的一组链接
 ·article:blog、杂志、文章汇编等中的一篇文章
 
  我们来考虑一个典型的blog 主页,它的顶部有页眉,底部有页脚,还有几篇文章、一个导航区和一个边栏,见代码1 典型的blog 页面
 
以下是代码片段:[www.xlnv.net]
<html>
<head>
<title>Mokka mit Schlag </title>
</head>
<body>
<p id="page">
<p id="header">
<h1><a href="https://www.xlnv.net">Mokka mit Schlag</a></h1>
</p>
<p id="container">
<p id="center" class="column">
<p class="post" id="post-1000572">
<h2><a href=
"/blog/birding/2007/04/23/spring-comes-and-goes-in-sussex-county/">
Spring Comes (and Goes) in Sussex County</a></h2>
 
<p class="entry">
<p>Yesterday I joined the Brooklyn Bird Club for our
annual trip to Western New Jersey, specifically Hyper
Humus, a relatively recently discovered hot spot. It
started out as a nice winter morning when we arrived
at the site at 7:30 A.M., progressed to Spring around
10:00 A.M., and reached early summer by 10:15. </p>
</p>
</p>
 
 
<p class="post" id="post-1000571">
<h2><a href=
"/blog/birding/2007/04/23/but-does-it-count-for-your-life-list/">
But does it count for your life list?</a></h2>
 
<p class="entry">
<p>Seems you can now go <a
href="https://www.wired.com/science/discoveries/news/
2007/04/cone_sf">bird watching via the Internet</a>. I
haven't been able to test it out yet (20 user
limit apparently) but this is certainly cool.
Personally, I can't imagine it replacing
actually being out in the field by any small amount.
On the other hand, I've always found it quite
sad to meet senior birders who are no longer able to
hold binoculars steady or get to the park. I can
imagine this might be of some interest to them. At
least one elderly birder did a big year on TV, after
he could no longer get out so much. This certainly
tops that.</p>
</p>
</p>
 
</p>
 
<p class="navigation">
<p class="alignleft">
<a href="/blog/page/2/">« Previous Entries</a>
</p>
<p class="alignright"></p>
</p>
</p>
 
<p id="right" class="column">
<ul id="sidebar">
<li><h2>Info</h2>
<ul>
<li><a href="/blog/comment-policy/">Comment Policy</a></li>
<li><a href="/blog/todo-list/">Todo List</a></li>
</ul></li>
<li><h2>Archives</h2>
<ul>
<li><a href='/blog/2007/04/'>April 2007</a></li>
<li><a href='/blog/2007/03/'>March 2007</a></li>
<li><a href='/blog/2007/02/'>February 2007</a></li>
<li><a href='/blog/2007/01/'>January 2007</a></li>
</ul>
</li>
</ul>
</p>
<p id="footer">
<p>Copyright 2007 Elliotte Rusty Harold</p>
</p>
</p>
 
</body>
</html>
 
  即使有正确的缩进,这些嵌套的p 仍然让人觉得非常混乱。在HTML 5 中,可以将这些元素替换为语义性的元素,见代码2 用HTML5编写的典型blog页面
 
以下是代码片段:[www.xlnv.net]
<html>
<head>
<title>Mokka mit Schlag </title>
</head>
<body>
<header>
<h1><a href="https://www.elharo.com/blog">Mokka mit Schlag</a></h1>
</header>
<section>
<article>
<h2><a href=
"/blog/birding/2007/04/23/spring-comes-and-goes-in-sussex-county/">
Spring Comes (and Goes) in Sussex County</a></h2>
 
<p>Yesterday I joined the Brooklyn Bird Club for our
annual trip to Western New Jersey, specifically Hyper
Humus, a relatively recently discovered hot spot. It
started out as a nice winter morning when we arrived at
the site at 7:30 A.M., progressed to Spring around 10:00
A.M., and reached early summer by 10:15. </p>
</article>
 
 
<article>
<h2><a href=
"/blog/birding/2007/04/23/but-does-it-count-for-your-life-list/">
But does it count for your life list?</a></h2>
 
<p>Seems you can now go <a
href="https://www.wired.com/science/discoveries/news/
2007/04/cone_sf">bird watching via the Internet</a>. I
haven't been able to test it out yet (20 user
limit apparently) but this is certainly cool.
Personally, I can't imagine it replacing
actually being out in the field by any small amount.
On the other hand, I've always found it quite
sad to meet senior birders who are no longer able to
hold binoculars steady or get to the park. I can
imagine this might be of some interest to them. At
least one elderly birder did a big year on TV, after
he could no longer get out so much. This certainly
tops that.</p>
</article>
<nav>
<a href="/blog/page/2/">« Previous Entries</a>
</nav>
</section>
 
<nav>
<ul>
<li><h2>Info</h2>
<ul>
<li><a href="/blog/comment-policy/">Comment Policy</a></li>
<li><a href="/blog/todo-list/">Todo List</a></li>
</ul></li>
<li><h2>Archives</h2>
<ul>
<li><a href='/blog/2007/04/'>April 2007</a></li>
<li><a href='/blog/2007/03/'>March 2007</a></li>
<li><a href='/blog/2007/02/'>February 2007</a></li>
<li><a href='/blog/2007/01/'>January 2007</a></li>
</ul>
</li>
</ul>
</nav>
<footer>
<p>Copyright 2007 Elliotte Rusty Harold</p>
</footer>
 
</body>
</html>
  现在不再需要p 了。不再需要自己设置class 属性,从标准的元素名就可以推断出各个部分的意义。这对于音频浏览器、手机浏览器和其他非标准浏览器尤其重要。

觉得可用,就经常来吧! 脚本宝典 欢迎评论哦! html5教程,巧夺天工,精雕玉琢。小宝典献丑了!

脚本宝典总结

以上是脚本宝典为你收集整理的html5教程-HTML5的结构和语义――结构(二)全部内容,希望文章能够帮你解决html5教程-HTML5的结构和语义――结构(二)所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。