I’m in the process of deploying a website which has recently been rebuilt in WordPress to take advantage of the CMS back end and easy administration. Though the site before WordPress was originally working fine in IE6/7/8, Firefox, Safari, Opera and Chrome I’m now looking for any cross-browser issues that have snuck in during development. These are some of the issues I’ve had (mainly with IE6’s rendering of the site) and how I’ve resolved them:
I’m using transparent PNGs both as within img tags and as background’s to some div elements. Transparent PNG’s do not render natively in IE6. Luckily, there is a fantastic plugin for WordPress which automagically applies one of a number of PNG fixes, called HITS- IE6 PNGFix. You simply install the plugin, configure it in the settings (which means choosing from 1 of 5 PNG fixes), and it just works. Under the hood, it’s simply using the
filter CSS property to do a
DXImageTransform on each of the relevant images. You may notice a little flicker if you have a lot of images whilst the images are processing, but it doesn’t take much time to do so. I also found I had the greatest success with the Twin Helix v2.0 method, as Unit and SuperSleight methods seemed to play with the background offsets I had set on my background images in the CSS.
I took the clients existing menu and made it dynamic, so that by adding a new page in the WordPress back end it would appear in the menu without needing any code. The menu is a simple CSS styled hierarchy of unordered lists, which makes appropriate use of the CSS
hover property to hide and show sub-menus. IE6 does not support hover except for on anchor tags. Luckily, I found this nifty little script which you plug into the behaviour property of your body tag and it does the rest.
To use within WordPress (I’m using the Hybrid theme framework):
- I copied this script into a file called
csshover.htc, and placed it into the root of the WordPress install
- Created an IE6 stylesheet called
ie.csswhich I placed in
/wp-content/themes/hybrid/library/css, adding the following line to it:
- span class=”st0″>"/csshover.htc");}
- Then, within the theme header
/wp-content/themes/hybrid/header.php, I added the following underneath the current stylesheet reference, to give us a conditional stylesheet which is only used in IE:
- <!–[if ie]>
- <link rel="stylesheet" href="/wp-content/themes/hybrid/library/css/ie.css" mce_href="/wp-content/themes/hybrid/library/css/ie.css" type="text/css" media="screen" />
Conditional stylesheets and CSS validation
There were also a number of fixes that were required due to box model issues that plague IE6. This was really easy to deal with now I had a conditional stylesheet, from above. In addition, the client required both the HTML and CSS validated, but IE specific hacks, which are often outside the CSS spec could now be relegated to
ie.css. For example, I used Lightbox, which uses the following CSS rule in its
lightbox.css that does not validate in the W3C CSS validator:
- span class=”coMULTI”>/* Trick IE into showing hover */}
I simply cut and paste this rule into
ie.css and was able to get the site to validate in the CSS validator. Success!
Hope this helps someone!