HTML5 语义化结构化规范化

2022-10-20,,,

html结构更加清晰、规范,学习html5优化结构的思路。
html5添加了一些新元素,用来标识常用的结构,是html更具语义化,可是我们无法直接使用,即使可能用到还要等他个十年八年的。
那就像微格式一样,使用class代替,或者随意点,使用id和class名来代替,让自己的结构更加清晰化,可以推广为规范,让团队协作更加顺畅。
一些新增的结构标记
◎section:这可以是书中的一章或一节,实际上可以是在html4中有自己的标题的任何东西
◎header:页面上显示的页眉;与head元素不一样
◎footer:页脚;可以显示电子邮件中的签名
◎nav:指向其他页面的一组链接
◎article:blog、杂志、文章汇编等中的一篇文章
一些例子
html5的文档结构

<header>...</header>
<nav>...</nav>
<article>
<section>...</section>
</article>
<aside>...</aside>
<footer>...</footer>

xhtml的文档结构

<divid="header">header</div>
<divid="nav">nav</div>
<divclass="article">
<divclass="section">section</div>
</div>
<divid="aside">aside</div>
<divid="footer">footer</div>

html5的图片结构

<figureid="fig2">
<legend>figure2.installmozillaxformsdialog</legend>
<imgalt="awebsiteisrequestingpermissiontoinstalltheollowingitem:mozillaxforms0.7unsigned"src="installdialog.jpg"/>
</figure>

xhtml的图片结构

<divclass="figure">
<h4class="legend">figure2.installmozillaxformsdialog</h4>
<imgalt="awebsiteisrequestingpermissiontoinstalltheollowingitem:mozillaxforms0.7unsigned"src="installdialog.jpg"/>
</div>

html5的加上标记

  m元素表示文本被“加上标志”,但是不一定要强调。可以把它想像成书中突出显示的一节。
  google的缓存页面就是典型的用例。如果链接到一个缓存的副本,搜索词就被加上标志。例如,如果搜索“egret”,那么缓存的google页面可能像下面这样:

thegreat<m>egret</m>(alsoknownastheamerican<m>egret</m>)isalargewhitewadingbirdfoundworldwide.thegreat<m>egret</m>flieswithslowwingbeats.thescientificnameofthegreat<m>egret</m>iscasmerodiusalbus.xhtml的加上标记thegreat<spanclass="m">egret</span>(alsoknownastheamerican<spanclass="m">egret</span>)isalargewhitewadingbirdfoundworldwide.thegreat<spanclass="m">egret</span>flieswithslowwingbeats.thescientificnameofthegreat<spanclass="m">egret</span>iscasmerodiusalbus.

《HTML5 语义化结构化规范化.doc》

下载本文的Word格式文档,以方便收藏与打印。