backward compatibility using HTML5 tags [duplicate]

落爺英雄遲暮 提交于 2021-02-08 09:51:06

问题


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

  2. 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)

  3. Here is the code:


    <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.


回答1:


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
History behind it: http://www.paulirish.com/2011/the-history-of-the-html5-shiv/



来源:https://stackoverflow.com/questions/22267417/backward-compatibility-using-html5-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!