webotech homepage Content © WOT Ltd - licensed under Creative Commons License

It started in the summer of 2006. I was on holiday with my girlfriend on the Black Sea coast in Bulgaria, her native country. As a young girl she used to spend her summer holiday's there and she was telling me how drastically it had all changed in recent years.

"Still, it would be nice to buy a small apartment here," she commented.

Less than six months later that passing remark had become a reality. We planned to use the property ourselves but also to rent it out, if we could. Given my software development skills, it was a natural step to set up a website which we could use to advertise the apartment.

That web site is bulgariaseaview.com. If you are after a more in-depth introduction, have a look at my first entry.

Styles Starting With Underscores

| | Comments (0) | TrackBacks (0)
Quick Fix

The quick fix is this: do not use CSS styles that begin with an underscore (_) if you want them to be rendered in IE 6. By the way, the bug in IE has been fixed in version 7.


IE CSS Underscore Bug

I was sort of aware of IE's CSS underscore hack but I was doing my best to forget it, since it's a piece of information which is as mundane as it is common with IE, "yet another problem with IE"
.
However, this issue must be related to that hideous hack.

This is a screenshot of what I wanted to achieve in IE 6:

ie6ok.gif
Simple enough, so I put together this HTML which should be absolutely fine:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>IE 6 - styles starting with underscore</title>
<style type="text/css">
._mOuter {position:relative;top:-2px;left:20px;}
._mTabOn,._mTabOff {width:100px;min-width:100px; text-align:center;
 font-size:14px;border:1px solid #000000;border-bottom-width:2px;
 border-top-width:2px;}
._mTabOn {background-color:#79B0D4;border-top-color:#79B0D4;}
._mTabOff {background-color:#497c9d;}
._mTabLn {color:#000000;display:block;padding:4px;}
._mTabSp {width:1px;background-color:#000000;}
a._mTabLn:link {text-decoration:none;}
a._mTabLn:visited {text-decoration:none;}
a._mTabLn:active {text-decoration:none;}
a._mTabLn:hover {background-color:#5c90b3;text-decoration:none;}
</style>
</head><body>
<table cellspacing="0" cellpadding="0" border="0" class="_mOuter">
 <tr>
  <td class="_mTabSp"></td>
  <td>
   <div class="_mTabOn"><a href="#" class="_mTabLn">Tab 1</a></div>
  </td>
  <td>
   <div class="_mTabOff"><a href="#" class="_mTabLn">Tab 2</a></div>
  </td>
  <td class="_mTabSp"></td>
 </tr>
</table>
</body></html>


However IE 6 renders this:

ie6notok.gif

Can you spot what's wrong? Most people would and I would argue that the difference is not acceptable for a public website, even though styles are subjective.

To fix it you simply change all the styles defined in the <style> tag that start with an underscore with styles that don't. Here is the working code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>IE 6 - styles starting with underscore</title>
<style type="text/css">
.XmOuter {position:relative;top:-2px;left:20px;}
.XmTabOn,.XmTabOff {width:100px;min-width:100px; text-align:center;
 font-size:14px;border:1px solid #000000;border-bottom-width:2px;
 border-top-width:2px;}
.XmTabOn {background-color:#79B0D4;border-top-color:#79B0D4;}
.XmTabOff {background-color:#497c9d;}
.XmTabLn {color:#000000;display:block;padding:4px;}
.XmTabSp {width:1px;background-color:#000000;}
a.XmTabLn:link {text-decoration:none;}
a.XmTabLn:visited {text-decoration:none;}
a.XmTabLn:active {text-decoration:none;}
a.XmTabLn:hover {background-color:#5c90b3;text-decoration:none;}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" class="XmOuter">
 <tr>
  <td class="XmTabSp"></td>
  <td>
   <div class="XmTabOn"><a href="#" class="XmTabLn">Tab 1</a></div>
  </td>
  <td>
   <div class="XmTabOff"><a href="#" class="XmTabLn">Tab 2</a></div>
  </td>
  <td class="XmTabSp"></td>
 </tr>
</table>
</body>
</html>


0 TrackBacks

Listed below are links to blogs that reference this entry: Styles Starting With Underscores.

TrackBack URL for this entry: http://www.webotech.co.uk/mt/mt-tb.cgi/4

Leave a comment

About this Entry

This page contains a single entry by Paul Mackinlay published on March 17, 2008 10:51 AM.

Setting the Scene was the previous entry in this blog.

Image Caching In IE is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages