All Guides

Underscore Hack

The Underscore Hack was a CSS technique that prefixed property names with underscores to target Internet Explorer 6 and earlier versions, exploiting IE's acceptance of invalid CSS syntax that other browsers would ignore. Properties like _width: 100px; would only be applied by IE6, allowing developers to serve browser-specific styles within the same CSS file. “css /* Regular CSS with IE6 underscore hacks mixed in */ .navigation { width: 200px; _width: 180px; /* Only IE6 reads this */ height: 300px; _height: 280px; /* IE6 box model compensation */ float: left; _display: inline; /* Fix IE6 doubled float margin */ background: #ffffff; _background: #f0f0f0; /* Slightly different for IE6 */ } /* More underscore hack examples */ .content { min-height: 400px; _height: 400px; /* IE6 fallback for min-height */ position: fixed; _position: absolute; /* IE6 doesn't support fixed */ }

Why Underscore Hack Matters

The Underscore Hack represented the widespread acceptance of invalid CSS as a practical solution to browser compatibility problems, highlighting how broken browser behavior forced developers to abandon web standards in favor of functional workarounds. This technique influenced discussions about CSS validation, code maintainability, and the long-term costs of relying on browser bugs rather than proper feature detection.