html5 当中nav怎么用,html5中nav标签的使用

HTML5中的新元素标签用来将具有导航性质的链接划分在一起,使代码结构在语义化方面更加准确,同时对于屏幕阅读器等设备的支持也更好。

一直以来,我们习惯于使用形如

id="nav">或

id="nav">这样的代码来写页面的导航;在HTML5中,我们可以直接将导航链接列表放到标签中:

  • href="index.html">Home

  • href="/about/">About

  • href="/blog/">Blog

根据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

  • href="/">Home

  • href="/events">Current

    Events

...more...

Demos

in Exampland

Written by A. N.

Other.

  • href="#public">Public

    demonstrations

  • href="#destroy">Demolitions

...more...

id="public">

Public

demonstrations

...more...

id="destroy">

Demolitions

...more...

...more...

href="?edit">Edit

|

href="?delete">Delete

|

href="?Rename">Rename

©

copyright 1998 Exampland

Emperor

在这个示例中,我们可以看到不仅可以用来作为页面全局导航,也可以放在标签内,作为单篇文章内容的相关导航链接到当前页面的其他位置。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值