The Artima Developer Community
Sponsored Link

Web Buzz Forum
The underscore hack

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Simon Willison

Posts: 282
Nickname: simonw
Registered: Jun, 2003

Simon Willison is a web technology enthusiast studying for a Computer Science degree at Bath Uni, UK
The underscore hack Posted: Nov 22, 2003 4:58 PM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Simon Willison.
Original Post: The underscore hack
Feed Title: Simon Willison: [X]HTML and CSS
Feed URL: http://simon.incutio.com/syndicate/markup/rss1.0
Feed Description: Simon Willison's [X]HTML and CSS cateory
Latest Web Buzz Posts
Latest Web Buzz Posts by Simon Willison
Latest Posts From Simon Willison: [X]HTML and CSS

Advertisement

Via Web-Graphics, Petr Pisar's Underscore Hack provides a new way of targetting CSS rules specifically at Internet Explorer on Windows. As with all such hacks, the pros and cons of using this approach need to be closely examined before deploying it. The hack takes advantage of the fact that adding an underscore to the start of a property name causes that declaration to be ignored by every browser except IE for Windows. However, the hack takes the dangerous step of using one bug to solve another. Peter-Paul Koch explained why this is a risky thing to do in a recent column for Digital Web magazine:

A certain browser has a certain CSS bug. Good to know. This same browser has another bug, usually in its parsing of CSS selectors or comments. This, too, is important information. However, a CSS hacker proceeds to use the second bug to "solve" the first one.

Solving one bug by another is not my idea of keeping Web development simple, but the matter goes beyond bad coding style. These hacks are inherently unsafe.

In an ideal world the next release of the browser would solve both bugs. In an uncaring world the next release of the browser would solve neither. In the uncertain world we live in the next release could solve one bug but not the other!

Therefore you could end up with a hack that applies an extra rule you no longer need, or with a necessary extra rule that isn�t applied any more.

In my opinion, hacks like this are safe for use on sites that are being actively maintained. If you use them in a "fire and forget" project you could well find it breaking in new browsers in a few years time, when the site is no longer being maintained but remains online and broken for all to see. If on the other hand you use it for a living, breathing site such as a constantly changing commercial project or a personal weblog errors that crop up in future browsers can be taken on as and when they appear.

When all is said and done, a large proportion of hacks in use today exist to combat the infamous box model problem - and the best advice for coping with that can be found on Dave Shea's CSS Crib Sheet: Try to avoid applying padding/borders and a fixed width to an element. Do that, and box model hacks just stop being necessary.

Read: The underscore hack

Topic: PyObjC Example Overload Previous Topic   Next Topic Topic: Javascript free rollovers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use