Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If I'm already using Modernizr, will I then even need HTML5 Shiv?

1) If I'm already using Modernizr, will I then even need HTML5 Shiv to enable HTML5 tag support for IE?

2) Is HTML5 Shiv only for IE, or for all browser who don't have native HTML 5 support? Like older versions of Firefox, Safari, Chrome, etc?

like image 454
Jitendra Vyas Avatar asked Jul 30 '11 12:07

Jitendra Vyas


People also ask

How you can use modernizr in HTML5?

Modernizr provides an easy way to detect any new feature so that you can take corresponding action. For example, if a browser does not support video feature then you would like to display a simple page.

What is the purpose of the HTML5 Shiv?

The HTML5 Shiv enables use of HTML5 sectioning elements in legacy Internet Explorer and provides basic HTML5 styling for Internet Explorer 6-9, Safari 4. x (and iPhone 3. x), and Firefox 3.

How does modernizr detect browser?

We can access various properties of this object 'Modernizr' for feature detection using “Modernizr. featureName”. For example, Modernizr. video will return “true” if the browser supports the video element, and false if the browser doesn't.

Where do I put modernizr?

The reason we recommend placing Modernizr in the head is two-fold: the HTML5 Shiv (that enables HTML5 elements in IE) must execute before the <body> , and if you're using any of the CSS classes that Modernizr adds, you'll want to prevent a FOUC.


1 Answers

1) If I'm already using Modernizer then even will I need HTML5 Shiv to enable HTML5 tag supports for IE.

You don't need to separately include html5shiv, because Modernizr includes it:

As of Modernizr 1.5, this script is identical to what is used in the popular html5shim/html5shiv library.

http://www.modernizr.com/docs/#html5inie


2) and is HTML5 Shiv only for IE or for all browser who don't have native HTML 5 support. like older version of Firefox, Safari, Chrome etc.

It's only for Internet Explorer.

Older versions of other browsers don't need it: http://caniuse.com/html5semantic

And the recommended snippet to include it is:

<!--[if lt IE 9]> <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> 

Which will only ever run for IE less than 9.

like image 144
thirtydot Avatar answered Oct 19 '22 22:10

thirtydot