mrforbes design - a web design and development studio

Blog - One Byte at a Time

Technology moves fast. Its hard to keep up. By the time you've mastered one tool, another has come along to replace it. You can't catch up, so just take it one byte at a time.

Archive for the ‘Firefox’ Category

Hacking CSS

Tuesday, August 14th, 2007

I’ve been building web sites since I was 17 years old - which was a long time ago. In the beginning, there was nothing but basic HTML, with tables for structure, and tags like font, b, i, etc. for presentation. It was a painful process, and with code differences between Internet Explorer and Netscape Navigator, it made everything more tedious.

Over 10 years later, and CSS has made building websites a much cleaner process, although I don’t think its become much simpler. Ten years, and the browser discrepencies continue, despite specified standards of how things SHOULD work. If you’re one of the few people viewing this in IE7… be glad to know that while Microsoft made your browser more pretty and added a few decent fixes and features, your rendering engine hasn’t changed, which means for us developers, the game is the same, only the hacks are different. In fact, Microsoft did fix the bug that allowed the star hack (*html) to target elements specifically in IE6. Too bad they didn’t fix half that problems that required its use in the first place. So, now we have the starchild hack (*:first-child+html) that will target IE7 only. Great.. two hacks for the price of one. free ringtones for cricket cell phone download nextel ringtones real tone ringtones cheap mobile ringtones virgin hot new ringtones free mobile phone ringtones 24 ringtones show tv free cellular south ringtones download verizon ringtones free nokia ringtones composer компютри втора употреба24 tv show ringtones free sprint ringtones 24 tv show ringtones free music real ringtones sprint download midi ringtones cingular download free ringtones info phone remember ringtones phone ringtones cricket ringtones free christian ringtones Thanks again MS.

I’ve been confronted with a choice of how to handle IE specific css. There are two methods to do this - one being making separate stylesheets for the different IE browsers, and placing their references into conditional comments, as shown below:

  1. <!–[if IE 6]><font style="position: absolute;overflow: hidden;height: 0;width: 0"><a href="http://www.videnov.com/">??????</a></font>
  2. <link rel="stylesheet" href="pathhere" />
  3. < ![endif]–>
  4.  
  5. <!–[if IE 7]>
  6. <link rel="stylesheet" href="pathhere" />
  7. < ![endif]–>

and the other being the ’star (or holly)’ hack, along with the ’starchild’ hack, mentioned above.

It DOES make sense to use conditional comments, and it is incredibly more valid and semantically correct than using hacks to output the proper css. So, I would tend to lean that way. However, the goal of any developer should be to make their CSS as cross-browser friendly as humanly possible without relying on hacks. So, say I have perhaps 1 selector that needs to be hacked? Should I create 2 new files with 2 new links on every page for 1 selector? It’s semantic, it validates… but it seems to be a lot of work for very little reward.

In cases like these, in my opinion its safe to break the validation and just hack the selector to get what you want. A little bit of muss, but no fuss. However, that begs the question… what point is the right point to use conditional comments instead? Thoughts are welcome.

Site Tags: