一份模板:

<body>
<header>
<hgroup>
<h1>Page title</h1>
<h2>Page subtitle</h2>
</hgroup>
</header> <nav>
<ul>
Navigation...
</ul>
</nav>
<section>
<article>
<header>
<h1>Title</h1>
</header>
<section>
Content...
</section>
</article>
<article>
<header>
<h1>Title</h1>
</header>
<section>
Content...
</section>
</article>
</section> <aside>
Top links...
</aside> <figure>
<img src="..."/>
<figcaption>Chart 1.1</figcaption>
</figure> <footer>
Copyright ©
<time datetime="2010-11-08">2010</time>.
</footer>
</body>

来自:http://slides.html5rocks.com/#semantic-tags-1

html5有丰富的语义化标签,在没有html5以前,你可能会这样写:

<html>
<head></head>
<body>
<div id="header"> </div>
<div id="nav"> </div>
<div id="content">
<div id="article"> </div>
<div id="sidebar"> </div>
</div>
<div id="footer"> </div>
</body>
</html>

Just looking at this HTML you can clearly see the different sections and just reading it you can clearly understand what each div will be used for thanks to the ID tags.

But how does the search engines know what these are for?

This is where HTML5 comes into it's own, below is the same structure but in HTML5.

<!doctype html>
<html>
<head></head>
<body>
<header> </header>
<nav> </nav>
<section>
<article> </article>
<aside> </aside>
</section> <footer> </footer>
</body>
</html>

Now again you can see exactly what these sections are and what content they are going to hold, but as these are defined tags the search engines will know what the sections are.

Semantic Tags

The main change with HTML5 is to create more semantic tags so they will explain what sort of content is going to be put into these tags.

Header

<header>

</header>

The header element represents a group of introductory or navigational aids.

A header element is intended to usually contain the section’s heading (an h1–h6 element or an hgroup element), but this is not required.

It will contain the header for the page and/or section therefore header can appear in multiple places on the page. Can also be an ideal place for logos, search forms or a table of contents for the page and/or section.

Nav

<nav>

</nav>

The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links. Not all groups of links on a page need to be in a nav element — only sections that consist of major navigation blocks are appropriate for the nav element.

Therefore an ideal place for a nav tag to go will be in a header or footer. A header will normally hold links which help navigate around the site, also a footer will normally hold important links for the website.

Section

<section>

</section>

Is the most generic of the new structural elements, containing content that can be grouped thematically or is related.

Section is the most generic of the structural tags, a section is defined as the thematic grouping of content. A section will typically content it's own header and content, which can be used separate to the page.

An example of a section would be a tabbed page or numbered sections of a page.

In typical web design you can separate the content of the website into different sections, introductions, features, news, contact etc. These example will be perfect candidates for section.

Aside

<aside>

</aside>

The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography.

Normally used for content which is related to the main content but can be independently moved, this is ideally used for quotes or a sidebar. They are linked to the page but can also be used independently.

Article

<article>

</article>

The article element consists of self-contained content in a document, page, application, or site.

The content of the article is intended to be independently distributed or reused elsewhere.

This is ideally used for page content, a forum post or a blog post. It can be separated from the page and still hold value. This area of the page can then be syndicated.

Footer

<footer>

</footer>

The footer element represents a footer for its nearest ancestor sectioning content. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.

Footers will normally appear at the end of a page but like headers you can have multiple footers per page as they are used to define the end of a section.

HGroup

<hgroup>

</hgroup>

The hgroup element represents the heading of a section. The element is used to group a set of h1–h6 elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.

(说明:

hgroup已经在html5.1中淘汰!

转自:http://www.paulund.co.uk/what-is-html5

HTML5 增加了很多语义化的标签,hgroup 就是其中一个,它用来表明标题的集合。如果有主标题、副标题,可以使用这个来包裹一下,一般比较常见的就是网站的标题和网站描述:

但是这样做并不是太必要,而且还有一些麻烦。一般来说,很难有单纯的 hn 标题标签集合在一起,通常还包含一些其他内容,但是使用 hgroup 包裹的内容,必须是 hn 标题标签,否则不会通过 HTML5 验证。又有谁会为了这么一个增强语义性用处不大的标签专门去生成一堆 hn 标签?

然后好消息是,这个标签在最新的 HTML5.1 版中被废除了,以后可以不再用了。但是又面临了一些问题,如果我有类似这种 声明主标题和对应副标题说明 的需求,我应该怎样增强语义性?

W3 给了一些结构建议,查看原文请点击这里。下面引用原文然后用我自己的博客标题做一个例子来介绍用其他方法模拟 hgroup 的语义性

使用标点符号分割

最简单的方法就是使用标点符号分割主标题和副标题:

<h1 ><a name="toc-2"></a>潜行者m: 关注前端开发热爱简约设计。</h1>

这种类型比较适合于文章标题,很显然不适合网站标题。

使用 span 标签标注副标题说明

<h1>潜行者m
<span>关注前端开发热爱简约设计。</span>
</h1>

这种方式比上面好一点,但是感觉还是怪怪的,但是结构比较简单,如果不怕麻烦,推荐下面一种方法。

使用 header 标签包裹标题和描述

header 也是 HTML5 新增的语义性标签,用来表示头部信息,一般不会被废弃。我们可以这样做:

<header>
<h1 ><a name="toc-5"></a>潜行者m</h1>
<p>关注前端开发热爱简约设计。</p>
</header>

强烈推荐这种写法,这样保证了语义性的同时,也保证了代码的整洁。

更多:

http://www.w3ctech.com/p/1087

html5 新增语义标签的更多相关文章

  1. html5新增语义标签

    1.header <header> 标签定义文档的页眉(介绍信息). 2.nav <nav> 标签定义导航链接的部分. 3.article <article> 标签 ...

  2. 浅谈html语义化标签,Html5新增语义化标签

    Html语义化标签,Html5新增语义化标签 自己在学习的期间,整理了下html关于语义化标签的一些知识,列的不是很全. 希望大家有新的见解可以给我留言,我会补充上去,谢谢大家 1.什么是语义化标签? ...

  3. HTML5新增Canvas标签及对应属性、API详解(基础一)

    知识说明: HTML5新增的canvas标签,通过创建画布,在画布上创建任何想要的形状,下面将canvas的API以及属性做一个整理,并且附上时钟的示例,便于后期复习学习!Fighting! 一.标签 ...

  4. HTML5新增video标签及对应属性、API详解

    知识说明: 比不上很牛的前端开发人员,但自始至终明白“万丈高楼平地起”,基础最重要,初学HTML5,稳固基础第一步,把最基本的整理下来,留下自己学习的痕迹.HTML5新增的video标签,将其属性以及 ...

  5. HTML5新增结构标签

    引言 在本节中,笔者将向大家讲述三部分内容,分别介绍HTML5时代的召唤,跟HTML4的区别,以及HTML5中带来的新的结构标签. HTML5时代的召唤 HTML4与HTML5的区别 HTML5新结构 ...

  6. HTML5新增的标签与属性

    一.关于DTD HTML5 不基于 SGML,所以不需要引用 DTD(HTML 4.01 基于 SGML) 二.HTML5结构标签 <header> 标记定义一个页面或一个区域的头部 &l ...

  7. HTML5新增的标签及使用

    HTML5和HTML其实是很相似的,但是有些内容有发生了改变,今天我学习了一下HTML5发现还是挺好学的,只要有html+css基础就可以,今天知识看了下新的标签. 一.定义文档类型 在文件的开头总是 ...

  8. html5新增语义化标签

    注意:body.section.nav 需要h1-h6. div.header则不需要. 1):<article> 显示一个独立的文章内容. 例如一篇完整的论坛帖子,一则网站新闻,一篇博客 ...

  9. HTML5之语义标签

    在HTML5标准中,新加了几个用于增添页面语义的标签,这些标签有:article.section.nav和aside等.与别的大多数标签不 同,浏览器在解释渲染这些标签的时候仅仅把它作为普通的div块 ...

随机推荐

  1. linux开启mysql远程登录

    Mysql默认root用户只能本地访问,不能远程连接管理mysql数据库,Linux如何开启mysql远程连接?设置步骤如下:1.GRANT命令创建远程连接mysql授权用户itloggermysql ...

  2. Bitmap 与ImageSource之间的转换

    public class ImageConverter { [DllImport("gdi32.dll", SetLastError = true)] private static ...

  3. 安卓手机用-----Exchange Activesync---同步Gmail日历联系人

    微软Exchange Activesync是一个跨平台的移动设备同步协议 支持很多手机操作系统,比如诺基亚的塞班.黑莓的palm.WindowsMobile.Iphone.安卓等.这些手机上都可以用这 ...

  4. MotionEvent的getX(),getY()与getRawX(),getRawY()区别

    getX()是表示Widget相对于自身左上角的x坐标,而getRawX()是表示相对于屏幕左上角的x坐标值(注意:这个屏幕左上角是手机屏幕左上角,不管activity是否有titleBar或是否全屏 ...

  5. 经验:Ubuntu 登陆 L2TP VPN

    Ubuntu Linux 操作系统默认支持PPTP协议的VPN登陆,但是随着网络环境的复杂化,我们需要使用L2TP协议的VPN登陆,下面,我们只需要简单的几条命令即可登陆L2TP协议的VPN.     ...

  6. ZOJ-3410Layton's Escape(优先队列+贪心)

    Layton's Escape Time Limit: 2 Seconds      Memory Limit: 65536 KB Professor Layton is a renowned arc ...

  7. 图的深度优先遍历DFS

    图的深度优先遍历是树的前序遍历的应用,其实就是一个递归的过程,我们人为的规定一种条件,或者说一种继续遍历下去的判断条件,只要满足我们定义的这种条件,我们就遍历下去,当然,走过的节点必须记录下来,当条件 ...

  8. SHDP--Working with HBase(三)之HBase+Phoenix实现分页

    先简单讲讲只用HBase来实现分页的思路: HBase利用scan来扫描表,通过startKey,stopKey来确定扫描范围,在需要进行分页时可以结合HBase提供的PagefFilter过滤扫描的 ...

  9. c语言的lua库编写

    gcc编译 gcc -I/usr/local/include/ -L/usr/local/lib/ -lm -o engine_mlisten_lua ./src/engine_mlisten_lua ...

  10. 面试前的准备---C#知识点回顾----01

    过完年来,准备找份新工作,虽然手里的工作不错,但树挪死,人挪活.咱不能一直在一个坑里生活一辈子,外面的世界毕竟是很美好的. 为了能正常的找到自己中意的工作,最近是将所有的基础知识拿出来复习了一次.仅作 ...