HTML5 Shiv
Encyclopedia
HTML5Shiv is a JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

 workaround to enable HTML5  elements
HTML element
An HTML element is an individual component of an HTML document. HTML documents are composed of a tree of HTML elements and other nodes, such as text nodes. Each element can have attributes specified. Elements can also have content, including other elements and text. HTML elements represent...

 in versions of Internet Explorer
Internet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...

 before version 9 that do not support elements that are not recognized, thus allowing them to be styled by CSS
CSS
-Computing:*Cascading Style Sheets, a language used to describe the style of document presentations in web development*Central Structure Store in the PHIGS 3D API*Closed source software, software that is not distributed with source code...

. While some people refer to it as "HTML5Shim" with respect to shim (computing), there is no real difference between the names and as noted in the code repository, the only difference is that "one has an m and one has a v - that's it."

Internet Explorer compatibility and version usage

Prior to version 9 of Internet Explorer there was little to no support for HTML5 elements and other HTML5 features. Internet Explorer still commands a large percentage Usage share
Usage share
Usage share refers to the relative market adoption of various products, for example:*Web browsers*BitTorrent clients*Operating systems*Web search engines*Instant messaging clients-See also:*Market share*Market value*Market power...

 according to the Usage share of web browsers
Usage share of web browsers
The usage share of a web browser is the proportion, often expressed as a percentage, of users of all web browsers who use that particular browser. This figure can only be estimated, typically by determining the proportion of visitors to a group of websites that use a particular web browser...

. Within the Internet Explorer percentage most of its usage comes from versions before 9, with version 8 holding the highest, followed by 7 and then 6. With its high usage percentage it is important to ensure that your webpage functions correctly in Internet Explorer, which is where the HTML5Shiv comes in. It allows Internet Explorer to recognize the HTML5 tags and allow them to be styled using CSS
CSS
-Computing:*Cascading Style Sheets, a language used to describe the style of document presentations in web development*Central Structure Store in the PHIGS 3D API*Closed source software, software that is not distributed with source code...

.

Usage

To enable the HTML5Shiv place the following section of code into the head element. This will load the HTML5Shiv from the Google Code
Google Code
Google Code is Google's site for developer tools, APIs and technical resources. The site contains documentation on using Google developer tools and APIs—including discussion groups and blogs for developers using Google's developer products....

 repository on the condition that the browser being used is a version of Internet Explorer earlier than version 9.





This must be placed in the head element because Internet Explorer needs to know about the elements before it renders them.

Example

Here is a simple example showing a before and after using the HTML5Shiv.

This following code should style any text using the
tag, new in HTML5, by increasing the font size and changing the color to orange.







Hello





Result in Internet Explorer 7:
Since Internet Explorer doesn't recognize the
tag it applies the default styling to it.

Now, we will add in the shiv.








Hello





Result:

Once the shiv has been used, Internet Explorer recognizes
as a valid tag and it can then be styled.

Support

The HTML5Shiv is licensed under the MIT License
MIT License
The MIT License is a free software license originating at the Massachusetts Institute of Technology . It is a permissive license, meaning that it permits reuse within proprietary software provided all copies of the licensed software include a copy of the MIT License terms...

and available from its Google code repository.

Updates are on going and a list of recent updates can be found here: http://code.google.com/p/html5shiv/updates/list.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK