美文网首页
HTML5的结构和语义(2):结构

HTML5的结构和语义(2):结构

作者: 爱上小媳妇 | 来源:发表于2020-04-01 10:47 被阅读0次

  由于缺少结构,即使是形式良好的 HTML 页面也比较难以处理。必须分析标题的级别,才能看出各个部分的划分方式。边栏、页脚、页眉、导航条、主内容区和各篇文章都由通用的 div 元素来表示。HTML 5 添加了一些新元素,专门用来标识这些常见的结构:

 · section:这可以是书中的一章或一节,实际上可以是在 HTML 4 中有自己的标题的任何东西

 · header:页面上显示的页眉;与 head 元素不一样

 · footer:页脚;可以显示电子邮件中的签名

 · nav:指向其他页面的一组链接

 · article:blog、杂志、文章汇编等中的一篇文章

  我们来考虑一个典型的 shouchaobao手抄报主页,它的顶部有页眉,底部有页脚,还有几篇文章、一个导航区和一个边栏,见代码1 典型的 blog 页面

<html>

<head>

<title>Mokka mit Schlag </title>

</head>

<body>

<div id="page">

<div id="header">

<h1><a href="http://www.9252.com/shouchaobao/">9252手抄报</a></h1>

</div>

<div id="container">

<div id="center" class="column">

<div class="post" id="post-1000572">

<h2><a href=

"/shouchaobao/birding/2007/04/23/spring-comes-and-goes-in-sussex-county/">

Spring Comes (and Goes) in Sussex County</a></h2>

<div 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>

</div>

</div>

<div 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>

<div class="entry">

<p>Seems you can now go 2020 五一劳动节手抄报<a

href="http://www.9252.com/shouchaobao/10749.html">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>

</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 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>

</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.9252.com/shouchaobao/">9252手抄报</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 2020 61儿童节手抄报<a

href="http://www.9252.com/shouchaobao/14065.html">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/">« _fcksavedurl=""/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>

  现在不再需要 div 了。不再需要自己设置 class 属性,从标准的元素名就可以推断出各个部分的意义。这对于音频浏览器、手机浏览器和其他非标准浏览器尤其重要。

  (待续)

相关文章

  • HTML5的结构和语义(2):结构

    由于缺少结构,即使是形式良好的 HTML 页面也比较难以处理。必须分析标题的级别,才能看出各个部分的划分方式。边栏...

  • HTML5标签语义化

    理解HTML5语义化:HTML5的语义化指的是用正确的标签包含正确的内容,标签语义化的好处就是结构良好,便于阅读,...

  • HTML5 新元素

    新的语义/结构元素 HTML5提供的新的元素可以构建更好的文档结构: 新的表单元素 新的输入类型 HTML5 - ...

  • 爬css

    1、html5的新特性(1)新增的语义/结构化标签,如 footer nav main article等(2)新增...

  • HTML5新元素

    New Semantic/Structural Elements(新的语义/结构性元素)#### HTML5为了更...

  • HTML5 新特性

    HTML5是HTML最新的修订版本。 HTML5 新特性 语义特性 HTML5赋予网页更好的意义和结构。新增了一些...

  • HTML5和HTML4的区别

    HTML5主要解决了以往文档的一些痛点: 解决文档结构混乱以前的文档结构过度依赖div,HTML5推出了多种语义化...

  • HTML5

    HTML5 1.语义化网页意义和结构2.本地存储特性==》localstorage,比如搜索商品历史记录,会存在l...

  • HTML5中的新元素

    下面是新的HTML5元素的列表,以及它们的用途的描述。 新的语义/结构元素 为了使文档结构更好,HTML5提供了新...

  • HTML5新增标签

    HTML5的特点:语义化标签语义化标签就是尽量使用有相应的结构的含义的Html的标签1.结构更好,更利于搜索引擎的...

网友评论

      本文标题:HTML5的结构和语义(2):结构

      本文链接:https://www.haomeiwen.com/subject/izjouhtx.html