我应该使用nav或ul [英] Should I be using nav or ul

查看:113
本文介绍了我应该使用nav或ul的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行导航菜单,应该使用< nav> 元素或< ul> 元素为<?p>

如果我使用 nav 我会prob需要使用shiv



如果是这样,使用 nav 优于 ul



编辑:



我知道你可以把 ul into a nav 我的问题是为什么使用 nav c>

$

解决方案

< ul>



Nav 是一个HTML5标记。如果你在HTML5中创建一些东西,你可以使用< nav> ,因为没有限制,但不是所有的浏览器都会正确显示。

 < nav> 
< ul>
< li>< a href =default.asp>首页< / a>< / li>
< li>< a href =news.asp>新闻< / a>< / li>
< li>< a href =contact.asp>联系人< / a>< / li&
< li>< a href =about.asp>关于< / a>< / li>
< / ul>
< / nav>




  1. 阅读有关Html 5

Ul 创建无序列表。无序意味着列表中的项目不会按任何特定顺序。您可以在 nav 中嵌入 ul 元素以放置您的链接。



详细了解HTML标记及其工作原理此处

 < ul> 
< li>< a href =default.asp>首页< / a>< / li>
< li>< a href =news.asp>新闻< / a>< / li&
< li>< a href =contact.asp>联系人< / a>< / li&
< li>< a href =about.asp>关于< / a>< / li>
< / ul>

这将创建一个导航栏,你必须把一些CSS样式看起来更好。 >

上面的两个代码将产生相同的结果。唯一的区别是 nav 告诉浏览器此元素用于导航目的。


I'm making a navigation menu, should I be using the <nav> element or <ul> element for that?

If I use a nav I'll prob need to use a shiv so that it works across browsers.

If that's so, what the advantage of using a nav over a ul?

EDIT:

I know you can put a ul into a nav my question is why use a nav at all?

解决方案

Don't get confuses with <nav> and <ul>. They both can be used together for a navigation menu.

Nav is an HTML5 tag. If you are creating something in HTML5 you can use <nav> as there is no restriction, but not all browser will render this correctly.

 <nav>
    <ul>
        <li><a href="default.asp">Home</a></li>
        <li><a href="news.asp">News</a></li>
        <li><a href="contact.asp">Contact</a></li>
        <li><a href="about.asp">About</a></li>
    </ul>
</nav>

  1. Read about Html 5

Ul creates an unordered list. Unordered means the items in the list will not be in any particular order. You can nest an ul element inside nav to place your links.

Read more about the HTML tags and how they work here.

<ul>
    <li><a href="default.asp">Home</a></li>
    <li><a href="news.asp">News</a></li>
    <li><a href="contact.asp">Contact</a></li>
    <li><a href="about.asp">About</a></li>
</ul>

This will create a navigation bar you have to put some CSS styles to look it better.

The above both code will produce the same result. The only difference is that nav tells the browser that this element is for navigation purpose s.

这篇关于我应该使用nav或ul的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆