Someone forwarded this CSS Hack I was looking for earlier. I was having an issue where Moz/Firefox was rendering something VERY different than Safari. Which was vexing. And I wasn’t aware of (or could remember) any CSS Hack that isolated ONLY Safari.
Then I found this Pound Safari Post Semicolon hack. At least, that’s what I think of it as. That’s right, I gave it an name. Even though I didn’t discover it. Don’t like it? Suck it. To me it shall be PSPS.
The rule itself it pretty brilliant, right up there with * html hack.
The rule is thus:
In your stylesheet, if you place the pound sign (#) after a semi-colon (;), all styles within those brackets and thereafter will be ignored in Safari.
Okay. For an example:
.container { background-color: #0c0; color: #fff; border: 1px solid #000; }
.container { background-color: #c00; border: 2px solid #000;# }
.container { background-color: #00c; 2px solid #000; }
In Safari, the background WILL NOT BE BLUE OR RED. Because of the # after the semi-colon on the second .container rule, that second and the third rule are ignored. So are any other rules after that pound sign.
So you can see the working of the code. Like I said, pretty slick when you need to isolate Safari.
Tagged As CSS
Comments are Open (4)
Posted at 04:11 AM
Comments
Justin French
Uhh, I can see the red background in my Safari Version 2.0.2 (416.12).
Posted by: Justin French | November 14, 2005 04:47 AM
Tony
Thanks for the quick heads-up Justin.
That was a mis-type on my part on what you should see. I've corrected that. It does work for Safari 2.0
Posted by: Tony | November 14, 2005 06:07 AM
some guy
thanks for the tip, monkey-boy, but what's a pound site?
"So are any other rules after that pound site."
also, the code would be a lot clearer if you used CSS colors instead of hex codes.
color: blue; color: red;
isn't writing for the wwwweb a bee-yatch?
Posted by: some guy | November 22, 2005 01:01 AM
Tony
I'd say thanks for pointing out the site/sign mis-typing, but then the rest of your comment just leaves me with a desire to tell you to "Eat Shit and Die on Christmas".
I mean, seriously. If you're trying to be snarky, at least use your name. How pathetic can you be that you feel the need to hide behind anonymity?
Posted by: Tony | November 22, 2005 03:30 AM