Dev Depot: HTML5 Shiv, Backwards Compatibility

Of all the current coding technologies holding the most promise for the future, HTML5 leads the way — but despite its potential, many developers shy away from upgrading their infrastructure to HTML5 — often using the excuse of incompatibility with older browsers to cover for an unwillingness to adapt or to learn new techniques.

This reluctance does have a legitimate foundation, however, as new elements are not recognized by older web browsers, cannot hold child elements, and are not affected by CSS styles, hindering HTML5’s adoption by many coders.

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

Programmer Sjoerd Visscher stumbled upon a workaround, and later posted the tip in a comment on W3C HTML WG co-chair Sam Ruby’s blog, stating, “BTW, if you want CSS rules to apply to unknown elements in IE, you just have to do document.createElement(elementName). This somehow lets the CSS engine know that elements with that name exist.”

The response from the stunned coding community was swift, as the implications became clear.

“I want to jam standards support into (this and future versions of) Internet Explorer,” John Resig stated, coining the term “HTML5 Shiv,” and notes, “If a shiv is the only pragmatic tool I can use to do so, shouldn’t I be using it?”

You should be using it too.

Fortunately, several solutions are available for helping cautious coders to explore this new frontier.

For example, the HTML5 Shiv (Code.Google.com/p/html5shiv) lets webmasters make their HTML5-based websites more backwards compatible with older browsing software that does not natively support the latest HTML5 web development standard by inserting a level of support via a JavaScript file.

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

Using the html5shiv is as easy as downloading a zip file and then inserting a call to the shiv's minified distribution within the web page's <head> element, either before or after the CSS calls. Here is the code:

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

“It must be included before the element (i.e. in the <head>) but it doesn’t matter if it appears before or after the CSS,” a rep advises. “But for the sake of performance it would make better sense to include the CSS first then this script.”The html5shiv is dual licensed under the MIT or GPL Version 2 licenses and the full, uncompressed source code is available, adding new HTML5 elements, and supports the printing of HTML5 elements, including default styles for elements such as “display: block” in HTML5’s article and section tags.

The publisher also addresses a common question: what is the difference between the html5shim and the html5shiv? The answer: nothing — one has an “m” and one has a “v” — that is it, so if you see information referring to html5shim, it is the same thing with a different name.

Because only Internet Explorer 9 or less will call the html5shiv code, it does not affect the performance of your site with other browsers, making the addition of this free script a no-brainer.

Related:  

Copyright © 2024 Adnet Media. All Rights Reserved. XBIZ is a trademark of Adnet Media.
Reproduction in whole or in part in any form or medium without express written permission is prohibited.

More Articles

opinion

Goodbye to Noncompete Agreements in the US?

A noncompetition agreement, also known as a noncompete clause or covenant not to compete, is a contract between an employer and an employee, or between two companies.

Corey D. Silverstein ·
opinion

The Search for Perfection in Your Payments Page

There has been a lot of talk about changes to cross sales and checkout pages. You have likely noticed that acquirers are now actively pushing back on allowing merchants to offer a negative option, upsell or any cross sales on payment pages.

Cathy Beardsley ·
opinion

Unpacking the Payment Card Industry's Latest Data Security Standard

The Payment Card Industry Data Security Standard (PCI DSS) is a set of requirements and guidelines that apply to all businesses that accept credit card payments, and is designed to ensure the security of those transactions.

Jonathan Corona ·
opinion

Compliance With State Age Verification Laws

During the past year, website operators have faced a slew of new state age verification laws entailing a variety of inconsistent compliance obligations.

Lawrence Walters ·
opinion

Merchants in Spotlight With Visa's VIRP

By now, most merchants know about the Visa Integrity Risk Program (VIRP) rolled out in spring 2023. The program is designed to ensure that acquirers and their designated agents — payment facilitators, independent sales organizations and wallets — maintain proper controls and oversight to prevent illegal transactions from entering the Visa payment system.

Cathy Beardsley ·
opinion

How to Know When Hosting Upgrades Are Really Needed

I was reminded about an annoyingly common experience that often frustrates website owners: upgrades. Sometimes, an upgrade of physical system resources like CPU, RAM or storage really is required to solve a problem or improve performance… but how do you know you’re not just being upsold?

Brad Mitchell ·
profile

WIA Profile: Natasha Inamorata

Natasha Inamorata was just a kid when she first picked up a disposable camera. She quickly became enamored with it and continued to shoot with whatever equipment she could afford. In her teens, she saved enough money to purchase a digital Canon ELPH, began taking portraits of her friends, shot an entire wedding on a point-and-shoot camera and edited the photos with Picnik.

Women in Adult ·
trends

Collab Nation: Top Creators Share Best Practices for Fruitful Co-Shoots

One of the fastest ways for creators to gain new subscribers and buyers, not to mention monetize their existing fan base, is to collaborate with other creators. The extra star power can multiply potential earnings, broaden brand reach and boost a creator’s reputation in the community.

Alejandro Freixes ·
opinion

Bridging Generational Divides in Payment Preferences

While Baby Boomers and Gen Xers tend to be most comfortable with the traditional payment methods to which they are accustomed, like cash and credit cards, the younger cohorts — Millennials and Gen Z — have veered sharply toward digital-first payment solutions.

Jonathan Corona ·
opinion

Legal and Business Safety for Creators at Trade Shows

As I write this, I am preparing to attend XBIZ Miami, which reminds me of attending my first trade show 20 years ago. Since then, I have met thousands of people from all over the world who were doing business — or seeking to do business — in the adult industry.

Corey D. Silverstein ·
Show More