使用HTML5标签向后兼容

使用HTML5标签向后兼容

问题描述:

  1. 我希望我的CSS甚至对于使用HTML5标签的旧浏览器也能正常工作.

  1. I Want my CSS to work properly even for old browsers that does uses HTML5 tags.

我已经使用了标记并定义了与之关联的样式,该样式对于新浏览器来说是完美的,但不适用于旧浏览器(标记中的文本呈现为普通文本)

I have used tag and defined a style associated with it, this style works perfect for new browser but doesn't work for old browser (text in tag is rendered as normal text)

以下是代码:


    <style>
    .nav {
      color: red
      }
    nav {
      display: block;
      background-color: blue
      }
    </style>
    <div>
     <nav class="nav">
      <p>this is nav text</p>
     </nav>

此代码不适用于旧版浏览器.
如何解决此问题,以便我使用的所有标记都应在所有浏览器中正确呈现.

This code does not work for old browsers.
How to solve this problem so as all tags used by me should render properly in all browsers.

在head元素中插入最小化的分布Shiv'(在CSS之前或之后):

Insert minified distribution shiv in head element' (after or before your CSS):

<!--[if lt IE 9]>
<script src="[PATH]/html5shiv.js"></script>
<![endif]-->

https://code.google.com/p/html5shiv/
https://github.com/aFarkas/html5shiv
它背后的历史记录: http://www.paulirish.com/2011/the-history-the-html5-shiv/