Load different CSS files for different browsers

  • Thread starter Thread starter Sehboo
  • Start date Start date
S

Sehboo

I have a CSS file which shows things perfectly in IE, but it doesn't
work in Opera. If I change the CSS file for opera then it doesn't work
in IE. We only support these two browsers.

What I need to do is find out which browser I am in. If it is IE then
load CSS1. If I am in opera then load CSS2.

it is a C# web application

How would I do this?

thanks
 
There are "browser hacks" you can do to share the same stylesheet which take
advantages of bugs in IE to feed it something different to opera.
You can also get the Request.UserAgent property and write somthing different
down for each browser. This is easiest done in a master page rather than the
1.1 route of having a css user control. In a master page you can do make the
<head> tag runat=server and add a literal control to it at run time with the
stylesheet link in it.

HTH

Ciaran O'Donnell
http://wannabedeveloper.spaces.live.com
 
Hi,
There are "browser hacks" you can do to share the same stylesheet which take
advantages of bugs in IE to feed it something different to opera.

However the bugs are corrected in IE7, and the hacks will stop working.
I wouldn't do this.

The best way is to code according to standards and to have your CSS
rendered accordingly, same in each browser.
You can also get the Request.UserAgent property and write somthing different
down for each browser. This is easiest done in a master page rather than the
1.1 route of having a css user control. In a master page you can do make the
<head> tag runat=server and add a literal control to it at run time with the
stylesheet link in it.

HTH

Ciaran O'Donnell
http://wannabedeveloper.spaces.live.com

HTH,
Laurent
 
Back
Top