我应该使用新的HTML5语义元素吗? [英] Should I use the new HTML5 semantic elements?

查看:99
本文介绍了我应该使用新的HTML5语义元素吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在升级我的网站,这涉及使用新的HTML5语义元素< nav> < header> < footer> < aside> < section> 比常规旧< div> 元素。

I'm in the process of upgrading my website, and this involves the decision of using the new HTML5 semantic elements <nav> <header> <footer> <aside> <section> over regular old <div> elements.

计划支持IE7和IE8,但我知道这些版本不支持上述语义元素。我已经阅读了像Modernizr,Initializr和HTML5shiv这样的插件,我知道旧的浏览器会支持新的元素 IF JavaScript已启用,但如果不是我应该做的是什么?

I do plan on supporting IE7 and IE8, but I know that these versions don't support the above semantic elements. I've read up about 'plugins' like Modernizr, Initializr and HTML5shiv, and I know that older browsers will then support the new elements IF JavaScript is enabled, but what am I supposed to do if it's not?

默认情况下,< html> 标记被赋予 -js ,如果启用了JavaScript,Modernizr / Initializr将用 js 替换此类。这一切都很好,但有一些我不确定的事情。

By default, the <html> tag is given the class of no-js and if JavaScript is enabled, Modernizr/Initializr replaces this class with js. That's all well and good, but there are some things I'm uncertain about. So far, what is covered?


  • 如果启用JavaScript,

  • reset.css 文件中,其他旧版本的浏览器支持这些新标签。
  • 现代浏览器都很好。

  • IF JavaScript is enabled, IE7 and IE8 are supported by Modernizr/Initializr.
  • With a reset.css file, other older browsers support these new tags.
  • Modern browsers are all fine.

  • 如果JavaScript被禁用,我应该对IE8及以下做什么? no-js 类被添加到< html> 标记,那么我到底该怎么办呢?

  • 如何在这里使用< noscript> 我不想让编码过大的页面。

  • IF JavaScript is disabled, what am I supposed to do about IE8 and below? The no-js class is added to the <html> tag, so what exactly can I do with that?
  • How can I use <noscript> to my advantage here? I don't want to make pages too large with coding.

因此,除了这些问题,我还想问一下真正值得使用这些标签,当我可以只使用好的ol'< div> 标签,它们都支持旧的浏览器,

So, aside from those questions, I also want to ask if it's really worth using these tags, when I can just use good ol' <div> tags which would both support older browsers and also keep file sizes down by eliminating the required coding to make the new tags work in older browsers?

谢谢你,
Dylan。

Thank you, Dylan.

推荐答案

这是一个很好的习惯,例如

It's good practice to use both, for example

<nav>
    <div>
        <ul>
        <!-- etc -->
        </ul>
    </div>
</nav>

如果你需要支持那些过时的浏览器,我不会做任何事。好处,如他们,是不值得的额外的努力。

If you need to support those obsolete browsers, I wouldn't do anything more than that. The benefits, such as they are, are not worth the extra effort.

这篇关于我应该使用新的HTML5语义元素吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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