I have a tough one here, but I think the benefit will be great...
I'm using the following CSS hack with PHP. The U variable in the file below is a constant, previously defined (before I include this file) as the URL such as http://example.com/. The P constant variable is defined as the physical file path like /var/www/example.com/. (The reason I have to use U and P for absolute pathing is because I use pretty URLs via Apache RewriteRule and it messes up the relative pathing.)
As you can see, I'm using the "link rel" technique to load a default style sheet, and for one for IE, and then another one for IE6. But for Safari and Opera, I tried the linkrel CSS hack technique and it failed -- FF was loading and interpreting the Opera and Safari stylesheets when I thought it might fail on the linkrel tag. So, I had to switch it to an inline CSS and use an @import url() call, but that failed because Opera and Safari wouldn't interpret the @import url() call. So, I had no choice but to switch context back to PHP and load it inline with a require() statement.
Well, the current arrangement in the file below works, but it means that the stylesheet for Opera and Safari is loading with all browsers (it's just not interpreted except by Opera and Safari).
I'd like to know how to get the linkrel or the @import working for Opera and Safari, instead.
<?php ?>
<? /*
***************************************************
DEFAULT STYLING (AND FIREFOX)
***************************************************
*/ ?>
<link rel="stylesheet" media="all" href="<?= U ?>css/default.css"/>
<style type='text/css'>
<? /*
***************************************************
SAFARI & GOOGLE CHROME STYLING (WEBKIT STYLING)
***************************************************
NOTE A LINKREL WILL GET INTERPRETED BY FF IF YOU DO IT LIKE THIS...
<link rel="stylesheet" media="screen and (-webkit-min-device-pixel-ratio:0)"
href="<?= U ?>css/safari.css"/>
...SO THAT CAN'T WORK. ALSO, IF YOU USE AN @import url('<?= U ?>css/safari.css'); TO
REPLACE WHERE I HAVE THE require() BELOW, THAT WON'T WORK EITHER BECAUSE
OPERA AND SAFARI DON'T SEEM TO UNDERSTAND THE @import DIRECTIVE IN CSS.
*/ ?>
@media screen and (-webkit-min-device-pixel-ratio:0){
<? require(P . 'css/safari.css'); ?>
}
<? /*
***************************************************
OPERA STYLING
***************************************************
*/ ?>
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0){
<? require(P . 'css/opera.css'); ?>
}
</style>
<? /*
***************************************************
IE (ALL) STYLING
***************************************************
*/ ?>
<!--[if IE]>
<link rel="stylesheet" media="all" href="<?= U ?>css/ie.css"/>
<![endif]-->
<? /*
***************************************************
IE6 STYLING
***************************************************
*/ ?>
<!--[if lte IE 6]>
<link rel="stylesheet" media="all" href="<?= U ?>css/ie6.css"/>
<![endif]-->