We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

pckujawa on 01/20/07


Tagged

css hack safari


Versions (?)


Who likes this?

11 people have marked this snippet as a favorite

Roshambo
basicmagic
banjomamo
1976dan
jacksont123
purpleraison
SpinZ
vali29
atnexxt
aziz
stoker


CSS hack to target Safari


Published in: CSS 


URL: http://www.ibloomstudios.com/article1/

I pulled this from Nicholas Gagne's blog at http://www.ibloomstudios.com/article1/

  1. Safari CSS Hack
  2. Friday, November 11, 2005 by Nicholas Gagne
  3.  
  4. Although I don't condone the use of CSS hacks, I know that someone may find this useful. I haven't seen this hack (or any Safari hack) before, so I decided to put it out there.
  5.  
  6. 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. If you are using Safari the background of the box below will be green, otherwise it will be red.
  7.  
  8. The background color of this box will appear green in Safari and red in other browsers.
  9.  
  10. Here is what the CSS code looks like:
  11.  
  12. #testBox{background:#063;color:#fff;padding:5px;margin-bottom:10px}
  13. #testBox{background:#c00;#}
  14.  
  15. Notice the pound sign. Most browsers will ignore this and continue reading the CSS, but in Safari it will cancel all styles within its containing brackets and all styles after that. Of course, this will not validate in CSS validators, so use at your own risk.

Report this snippet 

You need to login to post a comment.