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

  • ma801zda (Vélrænar þýðingar)
  • tapasbocnoa (HOWTO: Fix the hCalendar and hCard accessibility and i18n problems)
  • Siggi Palli (Vélrænar þýðingar)
  • Bjarni Rúnar (HOWTO: Fix the hCalendar and hCard accessibility and i18n problems)
  • Unnur María (Vélrænar þýðingar)
  • Már (Vélrænar þýðingar)
  • Valdís (Vélrænar þýðingar)
  • Már (Vélrænar þýðingar)
  • Hrafnkell (Vélrænar þýðingar)
  • Már (Vélrænar þýðingar)
  • Óli Gneisti (Vélrænar þýðingar)
  • Sindri (Vélrænar þýðingar)
  • Just To Say (The Elegant, Unobtrusive Javascript Workaround for "Click to activate and use this control")
  • Finnur (hCalendar og hCard ófýsilegir staðlar fyrir íslenska vefi?)

 

 

Yfirlit yfir þetta skjal

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