This script is the defacto way to enable use of HTML5 sectioning elements in legacy Internet Explorer.

Overview

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

What do these files do?

html5shiv.js

  • This includes the basic createElement() shiv technique, along with monkeypatches for document.createElement and document.createDocumentFragment for IE6-8. It also applies basic styling for HTML5 elements for IE6-9, Safari 4.x and FF 3.x.

html5shiv-printshiv.js

  • This includes all of the above, as well as a mechanism allowing HTML5 elements to be styled and contain children while being printed in IE 6-8.

Who can I get mad at now?

HTML5 Shiv is maintained by Alexander Farkas, Jonathan Neal and Paul Irish, with many contributions from John-David Dalton. It is also distributed with Modernizr.

If you have any issues in these implementations, you can report them here! :)

For the full story of HTML5 Shiv and all of the people involved in making it, read The Story of the HTML5 Shiv.

Installation

Using Bower

bower install html5shiv --save

This will clone the latest version of the HTML5 shiv into the bower_components directory at the root of your project and also create or update the file bower.json which specifies your projects dependencies.

Include the HTML5 shiv in the <head> of your page in a conditional comment and after any stylesheets.

<!--[if lt IE 9]>
	<script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->

Manual installation

Download and extract the latest zip package from this repositiory and copy the two files dist/html5shiv.js and dist/html5shiv-printshiv.js into your project. Then include one of them into your <head> as above.

HTML5 Shiv API

HTML5 Shiv works as a simple drop-in solution. In most cases there is no need to configure HTML5 Shiv or use methods provided by HTML5 Shiv.

html5.elements option

The elements option is a space separated string or array, which describes the full list of the elements to shiv. see also addElements.

Configuring elements before html5shiv.js is included.

//create a global html5 options object
window.html5 = {
  'elements': 'mark section customelement' 
};

Configuring elements after html5shiv.js is included.

//change the html5shiv options object 
window.html5.elements = 'mark section customelement';
//and re-invoke the `shivDocument` method
html5.shivDocument(document);

html5.shivCSS

If shivCSS is set to true HTML5 Shiv will add basic styles (mostly display: block) to sectioning elements (like section, article). In most cases a webpage author should include those basic styles in his normal stylesheet to ensure older browser support (i.e. Firefox 3.6) without JavaScript.

The shivCSS is true by default and can be set false, only before html5shiv.js is included:

//create a global html5 options object
window.html5 = {
	'shivCSS': false
};

html5.shivMethods

If the shivMethods option is set to true (by default) HTML5 Shiv will override document.createElement/document.createDocumentFragment in Internet Explorer 6-8 to allow dynamic DOM creation of HTML5 elements.

Known issue: If an element is created using the overridden createElement method this element returns a document fragment as its parentNode, but should be normally null. If a script relies on this behavior, shivMethodsshould be set to false. Note: jQuery 1.7+ has implemented his own HTML5 DOM creation fix for Internet Explorer 6-8. If all your scripts (including Third party scripts) are using jQuery's manipulation and DOM creation methods, you might want to set this option to false.

Configuring shivMethods before html5shiv.js is included.

//create a global html5 options object
window.html5 = {
	'shivMethods': false
};

Configuring elements after html5shiv.js is included.

//change the html5shiv options object 
window.html5.shivMethods = false;

html5.addElements( newElements [, document] )

The html5.addElements method extends the list of elements to shiv. The newElements argument can be a whitespace separated list or an array.

//extend list of elements to shiv
html5.addElements('element content');

html5.createElement( nodeName [, document] )

The html5.createElement method creates a shived element, even if shivMethods is set to false.

var container = html5.createElement('div');
//container is shived so we can add HTML5 elements using `innerHTML`
container.innerHTML = '<section>This is a section</section>';

html5.createDocumentFragment( [document] )

The html5.createDocumentFragment method creates a shived document fragment, even if shivMethods is set to false.

var fragment = html5.createDocumentFragment();
var container = document.createElement('div');
fragment.appendChild(container);
//fragment is shived so we can add HTML5 elements using `innerHTML`
container.innerHTML = '<section>This is a section</section>';

HTML5 Shiv Known Issues and Limitations

  • The shivMethods option (overriding document.createElement) and the html5.createElement method create elements, which are not disconnected and have a parentNode (see also issue #64)
  • The cloneNode problem is currently not addressed by HTML5 Shiv. HTML5 elements can be dynamically created, but can't be cloned in all cases.
  • The printshiv version of HTML5 Shiv has to alter the print styles and the whole DOM for printing. In case of complex websites and or a lot of print styles this might cause performance and/or styling issues. A possible solution could be the htc-branch of HTML5 Shiv, which uses another technique to implement print styles for Internet Explorer 6-8.

What about the other HTML5 element projects?

  • The original conception and community collaboration story of the project is described at The History of the HTML5 Shiv.
  • IEPP, by Jon Neal, addressed the printing fault of the original html5shiv. It was merged into html5shiv.
  • Shimprove, in April 2010, patched cloneNode and createElement was later merged into html5shiv
  • innerShiv, introduced in August 2010 by JD Barlett, addressed dynamically adding new HTML5 elements into the DOM. jQuery added support that made innerShiv redundant and html5shiv addressed the same issues as well, so the project was completed.
  • The html5shim and html5shiv sites on Google Code are maintained by Remy Sharp and are identical distribution points of this html5shiv project.
  • Modernizr is developed by the same people as html5shiv and can include the latest version in any custom builds created at modernizr.com
  • This html5shiv repo now contains tests for all the edge cases pursued by the above libraries and has been extensively tested, both in development and production.

A detailed changelog of html5shiv is available.

Why is it called a shiv?

The term shiv originates from John Resig, who was thought to have used the word for its slang meaning, a sharp object used as a knife-like weapon, intended for Internet Explorer. Truth be known, John probably intended to use the word shim, which in computing means an application compatibility workaround. Rather than correct his mispelling, most developers familiar with Internet Explorer appreciated the visual imagery. And that, kids, is etymology.

Comments
  • Racist joke in readme.md not funny enough

    Racist joke in readme.md not funny enough

    "John Resig, who used the term [shiv] for its slang meaning, a sharp object used as a knife-like weapon... As reasonable as the later [sic] explanation may seem, John is actually a well known homie."

    If we're going to make jokes about the disproportionate imprisonment of people of color that also imply that PoC are violent, can we at least try to make them funny? As it is, it just ends up being depressing. Also, it's a real shame to sell one's decency without at least garnering a guffaw or two.

    opened by ghost 61
  • Publish to the npm registry

    Publish to the npm registry

    Hi, Would you mind publishing versions to the npm registry?

    While having a package.json and linking to github works, you get a reinstall of the package every time you type npm install. html5shiv has no dependents so it seems quick, but in fact it should be hitting github everytime and possibly decompressing a tarball.

    opened by parris 18
  • Conflicting information in README: Browser support and implementation?

    Conflicting information in README: Browser support and implementation?

    I'm probably missing something obvious here ... If so, let me apologize in advance for my ignorance.

    With that said, could someone help me to understand why the README says this in one spot:

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

    ... and a bit further down, it says:

    Include the HTML5 shiv at the top of your <head> in a conditional comment before any stylesheets.

    <!--[if lt IE 9]>
        <script src="components/html5shiv/html5shiv.js"></script>
    <![endif]-->
    

    Just curious if using <!--[if lt IE 9]> (to be clear, that's "less than IE 9, right?) will cancel out the scripts positive effects on Internet Explorer 9, Safari 4.x (and iPhone 3.x), and Firefox 3.x?

    I've gotten the approval to drop IE < 9 for one of my latest projects, and I'm trying to determine if I can stop using html5shiv; if it's meant to only be applied to IE < 9, then I wont use it ... On the other hand, if it helps to make IE9 (and the others mentioned above) behave better, then I'd gladly keep it in my templates. :+1:

    Anyway, hoping someone can shed some light.

    Many thanks for the awesome code!!!! Amazing stuff!!!!

    opened by mhulse 17
  • < IE9 display issues with Cufon.

    < IE9 display issues with Cufon.

    A few sites using the HTML5shiv have suddenly (over the weekend 18th, 19th Feb) started displaying rendering problems. Cufon replaces the text, but system text is still visible behind.

    Appears to be anything below IE9.

    Only common denominator appears to be the html5shiv.

    No JS errors.

    opened by olliewells 14
  • investigate performance

    investigate performance

    https://twitter.com/#!/jdalton/status/149879504767156224

    The new html5shiv overwrites document.createElement() and has a big perf impact for IE — http://bit.ly/tOmtib

    anything can be done?

    opened by paulirish 14
  • Add basic usage details

    Add basic usage details

    Inexplicably, readme.md file doesn't contain any basic usage details (or clear pointers to such details). As simple as they are, it's important that first time users know the basics.

    opened by drzax 11
  • Permission denied error on Internet Explorer 9

    Permission denied error on Internet Explorer 9

    The second time the Print link is clicked on this test page in Internet Explorer 9 the following error triggers:

    Line: 31
    Error: Permission denied
    

    Launching the debugger highlights the following code in iepp.js:

    if(styleSheetList+'' === undefined)
    
    opened by slieschke 9
  • Added Support for the main structural element

    Added Support for the main structural element

    Added a DOMContentLoaded event listener that tests css property values. Specifically the display property is tested on the 'main' structural element for the sake of adding support for this element. The current Master branch version fails to adequately test support for 'main' in IE11, Opera, and some versions of Safari. Support for the 'main' element was also added to the testing files.

    opened by jbowyers 8
  • iepp causes window.print to print out all frames

    iepp causes window.print to print out all frames

    Have a look at the two pages in this gist.

    Each page has a Print link that attempts to only print out the contents of child document.

    If iepp.js is included in both documents, or only in parent document, the parent document is incorrectly printed out with an empty iframe where the child document appears when clicking on either Print link.

    If iepp.js is included in only the child document the parent document is incorrectly printed out with the child document appearing in the iframe when clicking either Print link.

    If iepp.js is removed from both documents both Print links will result in only the child document being printed as expected.

    I have observed this behaviour in Internet Explorer 6 through 9.

    opened by slieschke 8
  • Support tag names with colons like foo:bar

    Support tag names with colons like foo:bar

    createDocumentFragment doesn't support namespaced tag names such as "mj:pane." This can be fixed by changing

    getElements().join().replace(/[\w\-]+/g, function(nodeName) {
    

    to

    getElements().join().replace(/[\w\-|\w\:]+/g, function(nodeName) {
    

    This is a bit more elegant solution than proposed in #115 as that allowed anything to be tags whereas this just allowed hyphenated tags and namespaced tags.

    opened by imjoshdean 6
  • README: Missing HTML example?

    README: Missing HTML example?

    Stoopid question, but is it still recommended to use IE conditional:

    <!--[if lt IE 9]>
    <script src="dist/html5shiv.js"></script>
    <![endif]-->
    

    I've even been using:

    <!--[if (lt IE 9) & (!IEMobile)]>
    <script src="dist/html5shiv.js"></script>
    <![endif]-->
    

    I didn't see an example of this in the README, so does that mean I don't need to use the conditional comments anymore?

    If I do, or if it is best practice to use IE conditional comments, which syntax is best?

    Thanks! Micky

    opened by mhulse 6
Releases(3.7.3)
DNS-Blocklists: For a better internet - keep the internet clean!

DNS Blocklists - For a better internet! Multi - Cleans the Internet and protects your privacy! An all in one blocklist based on the OISD blocklist, ba

Gerd 280 Jan 2, 2023
Open-source NFID SDK for Internet Identity, a blockchain authentication system for the Internet Computer.

NFID-SDK is an open source software development kit that contains examples and packages for developers to integrate NFID into your application

Internet Identity Labs 15 Dec 23, 2022
Create a deep copy of a set of matched elements with the dynamic state of all form elements copied to the cloned elements.

jq-deepest-copy FUNCTION: Create a deep copy of a set of matched elements while preserving the dynamic state of any matched form elements. Example Use

Michael Coughlin 5 Oct 28, 2022
Fun way to share some of your (already) public StackOverflow user data to the internet.

ProfileOverflow A simple app leveraging StackExchange APIs to show some StackOverflow accounts information. Made for fun during a weekend as practice.

Jacky Efendi 5 Sep 14, 2022
An unofficial companion tool created for use alongside PhotoPrism to enable API endpoints and automation.

PhotoPrism Helper PhotoPrism Helper is an unofficial companion tool created for use alongside PhotoPrism. This project isn't associated with the Photo

Ryan Miller 9 Dec 25, 2022
An non-official esx-legacy 1.5 version for quasar inventory purpose.

Hi there ! It's my first post on github, and I'm releasing a free edited base with esx-legacy 1.5 compatible and made for Quasar Inventory. How can I

ChernyyOrel 3 Mar 19, 2022
radiQL, your one-stop-shop for migrating from a legacy REST backend to an efficient and modern GraphQL API

Welcome to radiQL, the one-stop solution for setting up GraphQL on a PostgreSQL database. Check out our Medium article here. At A Glance: Give us your

OSLabs Beta 90 Nov 14, 2022
A faster alternative to legacy node:querystring module

fast-querystring Fast query-string parser and stringifier to replace the legacy node:querystring module. Installation npm i fast-querystring Features

Yagiz Nizipli 95 Dec 17, 2022
Kâşif is a web based file explorer designed for every platform.

Kâşif the Explorer Kâşif Turkish noun Explorer A person who travels to places where few people have been before or places that are unknown to them, in

Muhammed Ali CAN 14 Jul 2, 2022
File Hider - This is a plugin for Obsidian that allows hiding specific files and folders from the file explorer

File Hider - This is a plugin for Obsidian that allows hiding specific files and folders from the file explorer

Oliver 24 Dec 16, 2022
🌘light.so - The Social Blockchain Explorer

light.so The Social Blockchain Explorer. Learn more > Discord · Website · Issues About The Project Ethereum for absolutely everyone The social blockch

Light 32 Dec 21, 2022
A more detailed discord data package explorer

Ever wondered what Data discord collects? Or did you ever want to view what's inside of a discord package? Discord Package is a customisable tool that allows you to view your data in a fancy way. You could also use our exporting feature to share your selected data with your friends.

Peter 220 Jan 5, 2023
Merge multiple JSON files - Vanilla JavaScript and HTML (graphic mode: browser+explorer)

JSON Merger Usage First, git clone project git clone https://github.com/mtacnet/json-merger.git Move to cloned repository and open generate.html with

Tac 1 Sep 18, 2022
The repo of Zenotta's block explorer

Zenotta Block Explorer It's the repo of Zenotta's block explorer! Official documentation » Set Up and Run The block explorer can be run in a dev envir

Zenotta AG 7 Dec 15, 2022
First blockchain explorer to navigate and visualize EIP-4844 blobs

Blobscan Blobscan is the first blockchain explorer that helps to navigate and visualize those EIP-4844 blobs, providing the necessary infrastructure t

Blossom Labs 6 Dec 29, 2022
Script to fetch all NFT owners using moralis API. This script output is a data.txt file containing all owner addresses of a given NFT and their balances.

?? Moralis NFT Snapshot Moralis NFT API will only return 500 itens at a time when its is called. For that reason, a simple logic is needed to fetch al

Phill Menezes 6 Jun 23, 2022
Script to synchronize between a Notion database and Google Calendar both ways. Uses Google App Script.

Yet Another Two Way Notion-Google Calendar Sync Script A script to sync events between Google calendar and a Notion database. Features! Google App Scr

kat 41 Jan 7, 2023
An easy way to animate SVG elements.

Walkway I loved the animations for the polygon ps4 review a few months back and decided to create a small library to re-create them (simple demo). It

Connor Atherton 4.4k Jan 2, 2023
Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls.

Hash.js - URL Hash Manipulation Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls. Tested in lates

Jonny Strömberg 152 Aug 1, 2022