November 14, 2005

Safari CSS Hack

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.

This box, with a class of `container`, is an example for Safari.

So you can see the working of the code. Like I said, pretty slick when you need to isolate Safari.

Post Info

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).

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

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?

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?

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu