Appendix A.  Modernizr

Modernizr is an open source JavaScript library that allows us to test for individual features of HTML5 in our users’ browsers. Instead of testing just for a particular browser and trying to make decisions based on that, Modernizr allows us to ask specific questions like: “Does this browser support geolocation?” and receive a clear “yes” or “no” answer.

The first step to using Modernizr is to download it from the Modernizr site, at http://modernizr.com.

Once you have a copy of the script, you’ll need to include the script file in your pages. We’ll add it to the head in this example:

<!doctype html> <html> <head> <meta charset="utf-8"> <title>My Beautiful Sample Page</title> <script src="modernizr-1.7.min.js"></script> </head> ...

Get HTML5 & CSS3 For The Real World now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.