======================================================
注:本文源代码点此下载
======================================================
html5中的新元素标签用来将具有导航性质的链接划分在一起,使代码结构在语义化方面更加准确,同时对于屏幕阅读器等设备的支持也更好。
一直以来,我们习惯于使用形如
或这样的代码来写页面的导航;在html5中,我们可以直接将导航链接列表放到标签中:
根据w3c的定义规范:
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. in particular, it is common for footers to have a list of links to various key parts of a site, but the footer element is more appropriate in such cases, and no nav element is necessary for those links.
一个页面中可以拥有多个元素,作为页面整体或不同部分的导航;下面是w3c给出的一个代码示例:
the wiki center of exampland
...more...
...more...
public demonstrations
...more...
demolitions
...more...
...more...
© copyright 1998 exampland emperor
在这个示例中,我们可以看到不仅可以用来作为页面全局导航,也可以放在标签内,作为单篇文章内容的相关导航链接到当前页面的其他位置。
======================================================
在最后,我邀请大家参加新浪APP,就是新浪免费送大家的一个空间,支持PHP+MySql,免费二级域名,免费域名绑定 这个是我邀请的地址,您通过这个链接注册即为我的好友,并获赠云豆500个,价值5元哦!短网址是http://t.cn/SXOiLh我创建的小站每天访客已经达到2000+了,每天挂广告赚50+元哦,呵呵,饭钱不愁了,\(^o^)/