Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type='text/css'>
#example { background: #ff0000;width:100px;height:100px } /* Moz/FF/IE8 beta2 */
*html #example { background: #00ff00; } /* IE6 */
*+html #example { background: #0000ff; } /* IE7 */
.demo { background: #ff0000;width:100px;height:50px } /* Moz/FF/IE8 beta2 */
*html .demo { background: #00ff00; } /* IE6 */
*+html .demo { background: #0000ff; } /* IE7 */
</style>
</head>
<title>css hack</title>
<body>
<div id="example">id示例</div>
<br />
<div class="demo">class示例</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type='text/css'>
#example { background: #ff0000;width:100px;height:100px } /* Moz/FF/IE8 beta2 */
*html #example { background: #00ff00; } /* IE6 */
*+html #example { background: #0000ff; } /* IE7 */
.demo { background: #ff0000;width:100px;height:50px } /* Moz/FF/IE8 beta2 */
*html .demo { background: #00ff00; } /* IE6 */
*+html .demo { background: #0000ff; } /* IE7 */
</style>
</head>
<title>css hack</title>
<body>
<div id="example">id示例</div>
<br />
<div class="demo">class示例</div>
</body>
</html>
在ie6下,二个div的背景为绿色,ie7下显示为蓝色,ff下显示为红色(ie8 beta2下显示跟ff相同)