HTML and CSS Reference
In-Depth Information
G.2.3. HTML5 Shiv
HTML5 Shiv is a shim (a small, compatibility-focused library) for enabling support for
HTML5's new elements in older versions of IE. That it's called HTML5 Shiv rather than
HTML5 Shim is an accident of history, but it does serve to differentiate it from the large
number of shims that have arisen around HTML5 in recent years. Download the latest ver-
sion from or use Modernizr (described in the next
section), which includes the Shiv.
G.2.4. Modernizr
One of the problems with using HTML5 is the lack of consistent browser support for the
various features defined in the specification. For example, the new autofocus attribute for
input elements works in Firefox4 but not in Firefox3.6. Safari4 didn't have support for
WebSockets; these were introduced in Safari5. With the ever-expanding set of features
in HTML5, and the ever-changing state of browser support among the major vendors, it
would be exhausting trying to maintain a list of which browser supports which feature.
You can use JavaScript to easily detect if the visitor's browser supports a particular feature.
For example, to check if they have support for offline applications, you'd use the following
This statement will evaluate to true if the HTML5 application cache is supported or
false if it is not. Unfortunately, not every HTML5 feature is detected in the same way.
Local storage is also implemented as a property of the window object. As such, you might
expect the following to work:
This will work in many places, but if you try to use it in a debugging tool like Firebug, it
will raise a security exception. Instead, you can consistently use the following statement:
'localStorage' in window
Search WWH ::

Custom Search