8 replies [Last post]
GAbOS
Offline
newbie
Last seen: 15 years 34 weeks ago
Joined: 2003-11-20
Posts: 8
Points: 0

I would like to load a specific CSS for each browser. but am unsure hwo to go about doing this. Any help would be great!
Thank you,
GAb

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 3 weeks 4 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Browser specific CSS

Hi GAbOS,
Firstly I wouldn't recommend doing this as it may cause maintenance headaches down the track.

But if it's what you want there are a couple of ways you could go about it.
One is to use a server side language such as PHP to detect the browser based on the user agent then adjust the page as required.
The main problem with this technique is that not all browser are who the claim to be.

Another technique would be to use CSS hacks to target certain browsers, http://centricle.com/ref/css/filters/ is a really any table of hacks that may help.

Why are you going down this path?

GAbOS
Offline
newbie
Last seen: 15 years 34 weeks ago
Joined: 2003-11-20
Posts: 8
Points: 0

Browser specific CSS

Well, firstly, I'm some what of a newb when it comes to CSS compatability, and it's tricks. I was wanting to keep the ability for browsers such as IE to resize text, but Opera handles this a diff way, by zooming the entire page, and when I wrote my CSS for IE, it totaly broke in Opera. I used percentages in teh CSS for text size, which did great for IE.

Thanks,
GAb

GAbOS
Offline
newbie
Last seen: 15 years 34 weeks ago
Joined: 2003-11-20
Posts: 8
Points: 0

Browser specific CSS

SO what would the easiest way to allow resizing in browsers that support resize, and keep it compatable across the board? Any ideas? I've done many searches on this, and am more confused now than before. Everyone seems to have different ideas about this matter.

Thank you again,
GAb

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 3 weeks 4 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Browser specific CSS

Hi GAbOS,
Here's a great link which explains how to size fonts. http://css-discuss.incutio.com/?page=FontSize
with links to other useful information on resizing.

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 12 years 5 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

Browser specific CSS

You could always discard layout considerations entirely, and just develop with heading and paragraph tags alone :roll:

At least then it'll work in every browser ever made!

GAbOS
Offline
newbie
Last seen: 15 years 34 weeks ago
Joined: 2003-11-20
Posts: 8
Points: 0

Browser specific CSS

I think Im going to just design two seperate style sheets, one for Opera, then one for everything else. I've gotten it to work pretty well in everything except Opera7. Can anyone point me to a thread or c/p what I would use JS wise to get this done? I dont mind doing the extra work if it means it functions correctly.

heh, Thanks Sven, I think I'll keep my design. Laughing out loud

GAb

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 3 weeks 4 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Browser specific CSS

Hi GAbOS,
This is one way to give opera it's own style sheet using JavaScript.
It's not something I would recommend but may do the trick until the next version of Opera comes out :roll:

 
<script type="text/javascript"> 
function isopera(){ 
var op=(navigator.userAgent.toLowerCase().indexOf('opera')==-1 ? false :true); 
 document.write((op==true)?"<link href='opera.css' rel='stylesheet'  type='text/css' />":"<link href='others.css' rel='stylesheet'  type='text/css' />"); 
} 
window.onload= isopera();
</script>

GAbOS
Offline
newbie
Last seen: 15 years 34 weeks ago
Joined: 2003-11-20
Posts: 8
Points: 0

Browser specific CSS

Thanks Tony, and I agree. I really dont want to resort to JS for borwser specific style sheets, but getting scalable fonts has been a hella headache for me, and everything I read makes me more confused than before. And I dont mind doing the extra work if it means compatability is increased.

Thanks again,
GAb