Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

load css based on browser?

Status
Not open for further replies.

fpower

MIS
Aug 12, 2003
54
US
Hello All,

I am new to programming so any help is greatly appreciated.
I have created a small web site with asp.net and C#. Things can be viewed fine on IE8, Firefox, & Chrome, but when I use IE 6 or 7, the formating is all messed up.

I would like to be able to have a css used based on whatever browser is being used...

can anyone give detailed example of how to use multiple style sheets, one for IE7 and below, one for IE8 and one for all other browsers?

thank you in advance for any help.
 
It's easy, just create a master stylesheet that is used by all the browsers. Then create one additional that includes fixes for older IE versions. Then use IE conditional comment to include this additional stylesheet in the html. Here's some more info on conditional comments:
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Vragabond's answer is the simplest, however you mentioned using asp.net and C# - so I thought I'd throw this in there too. Though for a pure HTML solution - go with Vragabond's answer.

I'm not as well versed in using .net for web development (I typically use PHP), but the concept should still be similar.

Upon building the page you could have your program check the user_agent string sent by the browser and put out the appropriate css. Though you could end up with people using other browser's and changing the user agent string to fool website.

Just a thought for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top