tags:

views:

43

answers:

6

we can get the browser name from javascript but is there any way to change css accordingly.I mean some classes of css file because I dont want to link another css file , I want to write styles on
if chrome

 a img
{
margin:0;
}

//if mozila

a img
{
margin:5px;
}
+1  A: 

There are two ways:

Client side: you need to use Javascript to detect the browser and import the appropriate CSS style. Have a look at this article.

Server side: you need to detect the user agent and serve the appropriate HTML. Here's a PHP source link for this.

Anax
+1  A: 

I have done this in the past with conditional includes. Detect the browser from its headers, then include a .css file based on the condition

DBQ
+1  A: 

What you're describing is conditional CSS (or for IE, conditional comments).

Jason Hall
+2  A: 

Maybe something like

body.chrome a img
{
margin:0;
}

body.mozilla a img
{
margin:5px;
}

then use Javascript to set a class on the body as required.

Matthew Wilson
A: 

u can detect with js the browser version. And link the right css file.

For IE you can use

Sometimes I use -moz-CSS_ATTRIBUTE für Mozila, but it works not everytime.

I think JS is the best solution

Fincha
+1  A: 

You can go for:

Sarfraz