dive into mark

You are here: dive into markArchivesJanuary 2003How to hide CSS from Safari: solution

Sunday, January 12, 2003

How to hide CSS from Safari: solution

Safari Spacer Hack. It can be used to apply CSS rules only to Safari, or used in reverse to hide CSS rules only from Safari. It rests on a parsing bug in Safari, which understands attribute selectors but does not understand attribute selectors with whitespace in a specific (valid) position. Example:

div.test {color:green;}
div[class~=test] {color:inherit;}
div[class ~=test] {color:green;}

This will make the div with class="test" green in every browser except Safari.

Dave Hyatt responds: Relying on these bugs in what should be a standards compliant parser is wrong.

I applied this hack to my own templates in an attempt to left-align my navigation bar. (Right-aligning it makes the links disappear completely in Safari.) The hack worked as advertised, but left-aligning the links triggered another bug in Safari that makes the links unclickable. I give up. Given the choice between presenting unclickable links and presenting no links at all, I choose no links.

Given that I am indirectly employed by Apple through the training courses I teach, I feel I have reached the limits of what I can say about Safari. I wish the Safari development team all the best in their quest for standards compliance. They know they have a long road ahead of them, and of course there are many other priorities competing for their limited time and resources. As for me, it’s time to move on and pursue other interests.

Filed under , ,

Respond privately

I am no longer accepting public comments on this post, but you can use this form to contact me privately. (Your message will not be published.)



Recent Stuff For You, Special Price Stay Here
  • Greasemonkey Hacks
Good Stuff Buy The Cow Go Away
Dive Into Python
Powered by Google Drink The Milk Don't Steal

 

posts / comments
© 2001-8 Mark Pilgrim