View Full Version : safari css

02-22-2007, 12:14 PM
is there a way to hack a class in css that ONLY mac safari reads.

eg; if u use,
* html .className {
margin: etc etc;

only IE will read it.


02-22-2007, 12:38 PM
you need to detect the browser using javascript then call in a specific CSS depending on what is detected..

<script type="text/javascript">

var bname=navigator.appName
var build =navigator.appVersion
var buildFloat=parseFloat(build) // build will be rounded


case 'Microsoft Internet Explorer': sheet = '<link href="default1.css" rel="stylesheet" type="text/css" />'; break;

case 'Netscape': sheet = '<link href="default2.css" rel="stylesheet" type="text/css" />'; break;

document.getElementById('css').innerHTML = sheet;
then where you would have your css call...
<link href="default.css" rel="stylesheet" type="text/css" />
Just replace with

<div id="css"></div>Please note i am looking at this from a programmers prospective not a web designers. Some guru will come back with a better solution

02-22-2007, 01:47 PM
Chris, it seems that a CSS hack specifically for Safari does not exist:

02-22-2007, 02:21 PM
::root .className {
margin: etc etc;

02-22-2007, 10:17 PM
thanks guys.

ranjan ill give that go...
its just annoying me coz safari isnt recongising a margin im setting on a class... im sure i can find a work around.

and dj... gaawd i dread the day i start having to do a seperate css for each browser - that means i can charge 3 times as much thou doesnt it... well im sure no client would buy that. roflol.


02-23-2007, 01:36 PM
gaawd i dread the day i start having to do a seperate css for each browser Nowadays there's no reason you should have to, but 5- 7 years ago it was the standard if you were doing CSS :)