Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Loading different stylesheets for different browsers

Reply
Thread Tools

Loading different stylesheets for different browsers

 
 
Andries
Guest
Posts: n/a
 
      09-08-2003
I would like my pages to load a specific stylesheet determined by what
browser the pages will be displayed on. I have found scripts to tell
me exactly what browser, version etc. is being used, but I am a bit
confused on exactly what the code should look like to choose the
correct stylesheet file.

Any help?
 
Reply With Quote
 
 
 
 
Chris Morris
Guest
Posts: n/a
 
      09-08-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Andries) writes:
> I would like my pages to load a specific stylesheet determined by what
> browser the pages will be displayed on. I have found scripts to tell
> me exactly what browser, version etc. is being used, but I am a bit
> confused on exactly what the code should look like to choose the
> correct stylesheet file.


Advice - don't do this. The HTTP User-Agent: header is not mandatory,
and may be incorrect even when it does exist. Depending on the
capabilities of your script, it may even incorrectly detect
identifiable agents such as Opera. Many browsers identify themselves
as something else and you can't tell the difference with the UA
header.

Instead, use the browsers' CSS-parsing capabilities to determine which
CSS they get to render. This way, you only need one stylesheet.

http://www.w3development.de/css/hide_css_from_browsers/

--
Chris
 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      09-08-2003
Chris Morris wrote:

> http://www.w3development.de/css/hide_css_from_browsers/


Furthermore, these techniques may help eliminate (network, rather
than local) caching problems.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?id=132

 
Reply With Quote
 
Sean Jorden
Guest
Posts: n/a
 
      09-08-2003
Chris Morris <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>
> Instead, use the browsers' CSS-parsing capabilities to determine which
> CSS they get to render. This way, you only need one stylesheet.
>
> http://www.w3development.de/css/hide_css_from_browsers/



Here's a question... I want to hide a CSS entry on the HTML tag itself from
IE. Since this is the top of the tree, I don't think child selectors will
work. Any ideas?


--
In theory there is no difference between theory and practice. In practice
there is. - YB
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      09-09-2003
Sean Jorden wrote:

> Here's a question... I want to hide a CSS entry on the HTML tag itself from
> IE. Since this is the top of the tree, I don't think child selectors will
> work. Any ideas?


Give the HTML a class or ID or some other attribute:

e.g. <html class="foobar">
<html id="foobar">
<html foo="bar">

and then use an attribute selector in the style sheet:

html[class=foobar] { color: red; }
html[id=foobar] { color: red; }
html[foo=bar] { color: red; }

In browsers that understand this syntax (only Opera and Gecko AFAIK), this
will count as more specific than just 'html {...}' in CSS and over-ride
any declarations made there. However, 'html.foobar {...}' and
'html#foobar {...}' are even more specific than that, so will over-ride
'html[class=foobar] {...}' and 'html[id=foobar] {...}'.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?id=132
 
Reply With Quote
 
Sean Jorden
Guest
Posts: n/a
 
      09-09-2003
Toby A Inkster <(E-Mail Removed)> wrote in
news(E-Mail Removed):

> Sean Jorden wrote:
>
>> Here's a question... I want to hide a CSS entry on the HTML tag
>> itself from IE. Since this is the top of the tree, I don't think
>> child selectors will work. Any ideas?

>
> Give the HTML a class or ID or some other attribute:
>



doh! for some reason I was giving <HTML> special status in my mind, it
didn't even occur to me that it could have and id or class. thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS stylesheets not loading in IE or firefox on XP SP2 Rschen7754 Computer Support 6 09-18-2009 02:22 PM
loading a single xml file with different stylesheets jim XML 1 07-24-2007 04:36 AM
Browsers, browsers! Quo vadis? El Kabong HTML 23 05-13-2007 08:55 PM
Two Browsers work! Two browsers won't load. Internet game service won't load jimmie Computer Support 1 02-26-2006 08:36 AM
Dynamically loading stylesheets =?Utf-8?B?QWxhbiBMYW1iZXJ0?= ASP .Net 3 11-24-2004 12:07 AM



Advertisments