Forum Moderators: not2easy

Message Too Old, No Replies

serve CSS by Browser Type

         

southarkwright

4:09 pm on Jun 3, 2005 (gmt 0)

10+ Year Member



I’m looking for a way to detect the browser type and serve a CSS style sheet based on the browser type. (IE, Opera, Mozilla etc)
If it breaks it down by version as well that would be fine.
I’ve found numerous ways to do this for PHP, but I’m using ASP. I haven’t found one that works well as of yet.
It also needs to work well with validated code (w3c) as the site it will be going on is validated for xhtml1.0

le_gber

10:08 pm on Jun 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



southarkwright,

Why would you want to deliver a different stylesheet to different browser? I understand the idea behind it, i.e. you want your page to look the same in all the browsers, but you are on the path for a lengthy and very time consuming development.

If you use XHTML and proper CSS you can achieve reasonably complex designs that will look and work the same in all major browsers (except the version 4.x and lower etc - but should you really worry about them as they represent a very small fraction of today's browser population).

If you really want to go ahead with it, you may want to use your favourite search engine and type 'asp browser sniffing' or 'javascript browser sniffing' because it is more of a client-side issue.

Hope this helps

Leo

drhowarddrfine

2:45 pm on Jun 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From what I had read I thought ASP.NET doesn't validate in most, if not all, cases? So I don't know if ASP would have that same problem?

southarkwright

4:32 pm on Jun 6, 2005 (gmt 0)

10+ Year Member



Actually im able to get the majority of browsers to look good with usually just one style sheet. I prefer more clean and simplistic designs and that keeps the amount of cross browser problems at bay. However in Opera, no matter what I do, all my text on my pages is centered. The same text shows fine in IE, Mozilla, Netscape and Firefox. I’ve run into other issues with Opera and created a style sheet specific for it.

I did locate a good Javascript code that worked with validation.

In regards to ASP validating.
I’m creating ASP based pages and have been able to validate all of them.

lonesome

9:33 am on Jun 7, 2005 (gmt 0)

10+ Year Member



There are various ways of using @import which prevent certain browsers from seeing the CSS file, see [imfo.ru...] for the full list and browser / standards support.
There's an article on [css-discuss.incutio.com...] which covers some of the techniques.

If your trying to fix an IE bug by using a different stylesheet for IE to override a standards compliant style then why not use IE's conditional comments see the quirksmode article [quirksmode.org...]