All Hail the CSS Underscore Hack

Written November 23. 2003, at 15:42 GMT.

Petr 'Pixy': The Underscore CSS Hack. This simple hack targets IE5.0 and above on Windows only and is a pleasant addition to the ever growing arsenal of simple CSS hacks that target various versions of IE on Windows and MacOS. Here's a quick run-through of these:

  • The "star html" hack targets IE5.0 and above on both Windows and MacOS.

  • Then there's also an equally relatively simple hack to target only IE5.0 and IE5.5 on Windows:

    .test {
      padding : 10px;
      width : 180px !important;
      width /**/: 200px;
      width : 180px;
      _width /**/: 200px;
    }

    Explanation of how this works:

    1. IE/Win applies all rules starting with underscore. IE on Windows doesn't respect the !important keyword in this context.
    2. IE6.0 has a comment parsing bug that makes it ignore everything after the /**/ part.
    3. All other browsers respect the !important keyword and thus ignore the second width declaration.
  • Then, finally, there's the class-name white-space parsing bug that that may be used to target IE5 on the Mac only.

P.S. The Underscore hack doesn't pass through W3C's CSS validator, but as explained by Petr 'Pixy' Staníček that's because the validator is broken - not the code.


More like this: English Entries, .


Reader Comments (1)

  1. Zato replies:

    Hvernig getur eitt fyrirtćki (veriđ er ađ tala um Micro Soft) veriđ svona lélegt en samt áhrifa mikiđ.

    Ég fć bara svoleis tár í augun ţetta er svo sorglegt.

    November 27. 2003 kl. 12:52 GMT | #

Ţessum svarhala hefur veriđ lokađ. Kćrar ţakkir til ţeirra sem tóku ţátt í umrćđunni.


 

Flakk um vefsvćđiđ



 

Nýleg svör frá lesendum

  • Rich (Req.js - javascript lazy-loading and dependency managment made easy)
  • Rich (Req.js - javascript lazy-loading and dependency managment made easy)
  • Rich (Req.js - javascript lazy-loading and dependency managment made easy)
  • Már (Req.js - javascript lazy-loading and dependency managment made easy)
  • Rich (Req.js - javascript lazy-loading and dependency managment made easy)
  • Már (Req.js - javascript lazy-loading and dependency managment made easy)
  • Dinesh (Req.js - javascript lazy-loading and dependency managment made easy)
  • Már (Taubleyjur í nútímanum - lítill leiđarvísir handa hrćddri ţjóđ)
  • Ada (Taubleyjur í nútímanum - lítill leiđarvísir handa hrćddri ţjóđ)
  • notandi (Taubleyjur í nútímanum - lítill leiđarvísir handa hrćddri ţjóđ)
  • Geir (Lausnin á efnahagsvandanum)
  • Jenný (Lausnin á efnahagsvandanum)
  • Óli Jens (Lausnin á efnahagsvandanum)
  • Már (Lausnin á efnahagsvandanum)
  • Kjartan S (Lausnin á efnahagsvandanum)

 

 

Yfirlit yfir ţetta skjal

(Atriđin í listanum vísa á ákveđna kafla ofar á síđunni.)