Browser Detection
From CSS Discuss
Several methods can be used to serve stylesheets based on what browser the visitor is using. Some work better than others.
- Java Script methods
- PHP methods
- Horde provides an excellent Browser class for browser sniffing.
- Server Side CSS Sniffing: Delivering specific style sheets to specific user agents.
- IE-only detection
- Conditional Comment ""s Pro: no Javascript; Con: helps detect IE5+ only
- CSS hacks
- Tantek Çelik’s band pass filters for IE 5.0, IE 5.5, IE 5.x and IE 5 Mac
Note that the HTML/CSS "media type" allows the user agent (not necessarily a browser) to select a specific stylesheet. For instance, when using code like
<link rel="stylesheet" href="tiny.css" type="text/css" media="handheld"/>
the "tiny.css" stylesheet will be invoked only by a "handheld"-eligible user agent (some cell phones, for example). See Media Stylesheets .
