Submit Your Article Forum Rules

Results 1 to 7 of 7

Thread: How to build multiple CSS style sheets for Different Browsers.

  1. #1

    How to build multiple CSS style sheets for Different Browsers.

    I'm kinda new to CSS, but I've been messing with it for off-and-on a month or so.

    I've been having problems with CSS always being interpreted differently by different browsers (i.e. IE from everybody else). Is there ANY way, using a PHP script, to retrieve a CSS script based on the browser using it?

    -Clif
    Clif Thompson

  2. #2
    WebProWorld MVP Webnauts's Avatar
    Join Date
    Aug 2003
    Location
    European Community
    Posts
    9,028

    Re: How to build multiple CSS style sheets for Different Browsers.

    Clif do you mean something like this? http://mikecherim.com/experiments/ph...er_sniffer.php

  3. #3
    Senior Member Narasinha's Avatar
    Join Date
    Aug 2003
    Posts
    230

    Re: How to build multiple CSS style sheets for Different Browsers.

    Quote Originally Posted by TheBrownRecluse View Post
    I'm kinda new to CSS, but I've been messing with it for off-and-on a month or so.
    Welcome aboard the CSS merry-go-round, Cliff. I hope you enjoy the ride.

    Quote Originally Posted by TheBrownRecluse View Post
    I've been having problems with CSS always being interpreted differently by different browsers (i.e. IE from everybody else). Is there ANY way, using a PHP script, to retrieve a CSS script based on the browser using it?
    This is almost always a problem. In the past, many "hacks" and workarounds have been used to provide different parts of the CSS to different browsers. CSS support in Mozilla-based browser like Firefox is now very robust, as it is in Opera. Users of Opera and Firefox/Mozilla have traditionally been among the users most likely to upgrade to the latest version. IE always seems to present problems though.

    My preferred method of handling this is to use conditional coments. This is supported in IE versions 5 and higher. The comments are treated as simply comments by browsers other than IE. You might read Arve Bersvendsen's article, Hack-free CSS for IE, or #IEroot — Targeting IE Using Conditional Comments and Just One Stylesheet by Hiroki Chalfant for more information.

    Yes, this still leaves out previous versions of IE, and it doesn't seem to address issues regarding IE for Macintosh, but it does help.
    - [url=http://unrelated.dexterityunlimited.com/Relatively Unrelated[/url]

  4. #4

    Re: How to build multiple CSS style sheets for Different Browsers.

    Quote Originally Posted by Webnauts View Post
    Clif do you mean something like this? http://mikecherim.com/experiments/ph...er_sniffer.php
    I tried the php sniffer and it doesn't seem to work. I changed the file name extension to .php, I know I have the compoenents on my server. I don't know what I'm missing, and I followed the instructions.
    Clif Thompson

  5. #5
    Junior Member
    Join Date
    Sep 2006
    Posts
    6

    Re: How to build multiple CSS style sheets for Different Browsers.

    I've been faced with this problem mysefl in so much as my template worked fine in FF, Safari, Opera & IE7 but not IE6 or below. In addtion I wanted to avoid any Javascript and I am not yet at a stage to implement PHP

    What I did find was the addition of an underscore or fullstop to a CSS element where by the only browsers to recognise the fullstoped element would be IE7 (& below) and the underscored element would be only recognised by IE6 (& below) as such you could use the following to define a different element height between IE6, IE7 & all other makes of browser

    p { height:100px; .height:200px; _height:300px; }

    Unfortunatly I cannot remember the url for where I found this but I have implemented the underscored element in my template in a couple of places, to great effect, where the formating went a little too out of sync in IE6 & IE5

    I am unsure if there is any longterm impact with using this method - I would be interested to hear from anyone who has encountered actual problems with this method

  6. #6
    WebProWorld MVP DaveSawers's Avatar
    Join Date
    Dec 2006
    Location
    Lunenburg, Nova Scotia, Canada
    Posts
    760

    Re: How to build multiple CSS style sheets for Different Browsers.

    Yuk! Better to do proper browser detection and have completely separate style sheets, See my reply to the other post on this topic: http://www.webproworld.com/graphics-...tml#post324562
    Dynamic Software Development
    www.activeminds.ca

  7. #7
    Junior Member
    Join Date
    Jun 2007
    Posts
    6

    Re: How to build multiple CSS style sheets for Different Browsers.

    I'd honestly suggest against browser sniffing because it's really not reliable when browser can so easily cloak themselves as other browsers (Opera comes to mind as a common example which loves to pretend to be IE).

    Conditional comments are a strong solution for fixing minor issues with IE and that's what I'd suggest if IE is the only one you are having issues with.

Similar Threads

  1. Style sheet switcher and hiding style sheets
    By kgun in forum Accessibility and Usability Forum
    Replies: 0
    Last Post: 03-05-2007, 09:43 AM
  2. User selectable Style Sheets?
    By jordanmcclements in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 03-10-2005, 10:22 AM
  3. dynamically linked style sheets?
    By hommealone in forum Web Programming Discussion Forum
    Replies: 14
    Last Post: 02-25-2005, 08:29 PM
  4. Cascading Style Sheets
    By WPW_Feedbot in forum Graphics & Design Discussion Forum
    Replies: 0
    Last Post: 12-15-2004, 10:59 AM
  5. CSS style sheets and H1 tags
    By computers in forum Graphics & Design Discussion Forum
    Replies: 5
    Last Post: 02-01-2004, 02:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •