为什么使用HTML5标签? [英] Why use HTML5 tags?

查看:136
本文介绍了为什么使用HTML5标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

新的HTML5元素像< section>和<物品>毫无意义?

我决定最终转向设计网站在HTML5中。我有一个关于新标签的问题。

I have decided to, finally, make the move to designing websites in HTML5. I have one question about the new tags.

有新标签,例如;页眉,页脚,导航栏等。为什么这些标签优先于使用DIV ID的旧方法(例如< div id =header> )。我可以看到为什么这会使事情变得更简单但是让一些使用HTML5的标签和一些使用旧方法的标签不会更令人困惑?我个人认为,使用全部或全部,而不是混合物更合乎逻辑。

There are new tags such as; header, footer, navbar, etc.. Why are these tags preferred over the older method of using DIV ID's (eg. <div id="header">). I can see why this would make things simpler but wouldn't it be more confusing to have some tags that use HTML5 and some tags that use the older method? I, personally, find it more logical to use all or none, rather than a mixture.

如果我完全忽略这一点,请告诉我。

If I'm missing the point entirely please let me know.

推荐答案

这不是一种情况。 HTML5仍有< div> s。它仍然有< span> s。新标签可以为您提供更具表现力的自由并标准化常见元素。例如,大多数页面都有导航栏,但到目前为止,还没有关于如何标记的标准。如果它们被明确标记为< nav> ,程序可以开始高效地使用此信息。搜索引擎可以忽略或解析它们,辅助技术可以帮助用户浏览网站。

It's not an either-or situation. HTML5 still has <div>s. It still has <span>s. The new tags are there to give you more expressive freedom and to standardize common elements. For instance, most pages have navigation bars, yet so far there was no standard for how those were marked up. If they're clearly marked up as <nav>, programs can start to use this information productively. Search engines can ignore or parse them and assistive technology can help the user navigate around the site.

它还使您更容易使用代码。 < nav> < div class =main nav foobar baz>

It also makes it easier for you to work with your code. <nav> is so much easier to spot than <div class="main nav foobar baz">.

新标签是添加,而不是替换旧标签的全新标签。

The new tags are an addition, not an entirely new set replacing the old tags.

这篇关于为什么使用HTML5标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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