由于缺少结构,即使是形式良好的 html 页面也比较难以处理。必须分析标题的级别,才能看出各个部分的划分方式。边栏、页脚、页眉、导航条、主内容区和各篇文章都由通用的 div 元素来表示。html 5 添加了一些新元素,专门用来标识这些常见的结构:
· ction:这可以是书中的一章或一节,实际上可以是在 html 4 中有自己的标题的任何东西
· header:页面上显示的页眉;与 head 元素不一样
· footer:页脚;可以显示电子邮件中的签名
· nav:指向其他页面的一组链接
· article:blog、杂志、文章汇编等中的一篇文章
我们来考虑一个典型的 blog 主页,它的顶正方形的边长部有页眉,底部有页脚,还有几篇文章、一个导航区和一个边栏,见代码1 典型的 blog 页面
<html>
<head>
<title>mokka mit schlag </title>
</head>
<body>
<div id=”page”>
<div id=”header”>
<h1><a href=”http://www.elharo.com/blog”>mokka mit schlag</a></h1>
</div>
<div id=”container”>
<div id=”center” class=”column”>
<div class=”post” id=”post-1000572″>
<h2><a href=
“/blog/birding/2007/04/23/spring-comes-and-goes-in-susx-county/”>
spring comes (and goes) in susx county</a></h2>
<div class=”entry”>
<p>yesterday i joined the brooklyn bird club for our
annual trip to western new jery, 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., progresd to spring around
10:00 a.m., and reached early summer by 10:15. </p>
</div>
</div>
<div class=”pos卡通图片 可爱女生t” 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>
<div class=”entry”>
<p>ems you can now go <a
href=”http://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 ur
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 nior 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>
</div>
</div>
</div>
<div class=”navigation”>
<div class=”alignleft”>
<a href=”/blog/page/2/”>« _fcksavedurl=””/blog/page/2/”>«” previous entries</a>
</div>
<div class=”alignright”></div>
</div>
</div>
<div id=”right” class=”column”>
<ul id=”sidebar”>
<li><h2>info</h2>
<ul>
<li><a hr脚踏实地作文ef=”/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>
</div>
<div id=”footer”>
<p>copyright 2007 elliotte rusty harold</p>
</div>
</div>
</body>
</html>
即使有正确的缩进,这些嵌套的 div 仍然让人觉得非常混乱。在 html 5 中,可以将这些元素替换为语义性的元素,见代码2 用 html5编写的典型blog页面
<html>
<head>
<title>mokka mit schlag </title>
</head>
<body>
<header>
<h1><a href=”http://www.elharo.com/blog”>mokka mit schlag</a></h1>
</header>
<ction>
<article>
<h2><a href=
“/blog/birding/2007/04/23/spring-comes-and-goes-in-susx-county/”>
spring comes (and goes) in susx county</a></h2>
<p>yesterday i joined the brooklyn bird club for our
annual trip to western new jery, 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., progresd 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>ems you can now go <a
href=”http://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 ur
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 nior 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/”>« _fcksavedurl=””/blog/page/2/”>«” previous entries</a>
</nav>
</ction>
<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>
现在不再需要 div 了。不再需要自己设置 class 属性,从标准的元素名就可以推断出各个部分的意义。这对于音频浏览器、手机浏览器和其他非标准浏览器尤其重要。
(待续)
本文发布于:2023-04-03 07:58:26,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/4b23254e0680ee154f8cb97ecf83d17b.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:HTML5的结构和语义(2):结构.doc
本文 PDF 下载地址:HTML5的结构和语义(2):结构.pdf
留言与评论(共有 0 条评论) |