Home

How to Manage Browser Incompatibility for HTML5 and CSS3 Programming

|
Updated:  
2016-03-26 13:16:16
|
HTML5 and CSS3 All-in-One For Dummies
Explore Book
Buy On Amazon

Although all the modern browsers manage CSS3 pretty well these days, Internet Explorer (especially the earlier versions) is well known for doing things in non-standard ways. Here are a few tricks to help you deal with the incompatibility.

How to make Internet Explorer–specific code

It’s a little easier for you to see how conditional comments work by viewing a simple example and then seeing how to use the conditional comment trick to fix CSS incompatibility problems.

Here is a simple page with Firefox.

image0.jpg

Here it is displayed in IE 7.

image1.jpg

Take a look at the code for IEorNot.html and see how it works.

<!DOCTYPE html>
<html lang = "en-US">
 <head>
 <meta charset = "UTF-8">
 <title>IEorNot.html</title>
 </head>
 <body>
 <p>
  I will now use a conditional comment to determine your
  browser. I’ll let you know if you're using IE.
 </p>
 <!--[if IE]>
  <h1>You're using IE</h1>
 <![endif]→
 </body>
</html>

The only part that’s new is the strange comments:

 <!--[if IE]>
  <h1>You're using IE</h1>
 <![endif]→

Conditional comments are a special feature available only in Internet Explorer. They allow you to apply a test to your browser. You can place any HTML code you wish between

About This Article

This article is from the book: 

About the book author:

Andy Harris earned a degree in Special Education from Indiana University/Purdue University–Indianapolis (IUPUI). He taught young adults with severe disabilities for several years. He also taught himself enough computer programming to support his teaching habit with freelance programming.
Those were the exciting days when computers started to have hard drives, and some computers connected to each other with arcane protocols. He taught programming in those days because it was fun.
Eventually, Andy decided to teach computer science full time, and he still teaches at IUPUI. He lectures in the applied computing program and runs the streaming media lab. He also teaches classes in whatever programming language is in demand at the time. He has developed a large number of online video-based courses and international distance education projects.
Andy has written several books on various computing topics and languages including Java, C#, mobile computing, JavaScript, and PHP/MySQL.
Andy welcomes comments and suggestions about his books. He can be reached at [email protected].