Senior Trainer-Instructor- Developer C++ / C UNIX & Web-JAVA / J2EE,PhD or Masters
WSI Nationwide, Inc.
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Browser Detection and Appropriate CSS Generation
Whoever said CSS would solve all your cross-platform browser display issues needs to lay off the pipe a little. I have yet to get CSS to work perfectly across all browsers / platforms, but I have gotten it to work "good enough" to get by.
I did it by using some fairly simplistic browser detection, as in recycling a library I wrote for SourceForge (which was recycled from a library on GotoCity.com).
Here are some of the things I discovered while setting up CSS on a handful of sites:
  1. If you don't set a font at all, users will complain because their browser defaults are either too big or too small - as if it's your fault.
  2. Using the CSS1 font-size: tag with a specific point size like 12pt breaks some browsers on some platforms (Netscape on Wintel).
  3. Even if that weren't the case, point sizes are different on different platforms (Macs display fonts smaller than Windows).
  4. And even if they rendered the same across all platforms, it's a really bad idea to hard-code sizes, as there are many people with impaired vision. When you hard-code a point-size, they can't override the size with their browser, and thus can't see your site. One of the worst sites on the internet is CNN.com, which hard-codes very small fonts into their CSS sheet.
  5. Because of this, you should stick with scaling percentages or the size syntax (small, medium, x-small, etc).
With those hard-learned lessons in mind, you can design a browser-smart CSS sheet and generate it with PHP. I won't go into details on CSS here. You can view the spec and examples at http://www.w3.org/Style/CSS/Test/19981002/.
Most of that spec was completely ignored by the geniuses at Netscape and Microsoft, which is why it has become such a headache for developers.
[ Next Page ]


Comments:
RE: javascript:history.back()Mike01/13/06 08:45
RE: javascript:history.back()Srinivasan11/18/04 03:21
RE: javascript:history.back()Alex Livingstone04/17/04 00:21
updating for netscape 4+/7abbey01/30/03 14:27
RE: Browser detection and CSSBradley Jareczek01/15/03 21:04
alternative for browser detectionBradley Jareczek01/15/03 21:02
Server-side css generation is not a good ideaScott Davey01/09/03 04:00
Getting the code in Tim's article to workNorman Graham12/16/02 07:01
RE: How get the client screen size?Christian12/03/02 02:39
css doesn't need php to detect the browserKristof Neirynck11/06/02 03:57
RE: Sniffer codeHirvi10/14/02 19:45
PHP & CSS - A Step FurtherJohn Krische09/17/02 23:56
Browser detection and CSSPraggers08/09/02 06:09
RE: The (in)famous CSS trickChris Berry06/09/02 10:14
RE: how to implement this?ars06/06/02 16:28
php CSS GeneratorHarry Fuecks05/08/02 12:14
RE: simpler: generating external CSS with php.ShellyMac03/19/02 14:44
how to implement this?Kassim Kasmani03/05/02 16:33
Browser detection CSS IE6Michael Hitchcock02/07/02 14:14
Has anyone actually gotten this to work?Brett02/04/02 17:23
Wish this would actually workBrett Farrey01/16/02 12:34
how can I create a .css file and a linkage?louis01/10/02 22:03
Browser detection for OperaHarry Oosterveen01/09/02 06:07
RE: The (in)famous CSS trickChance Warner01/07/02 19:17
RE: The (in)famous CSS trickJonas aka Hemlige Arne11/09/01 05:10
Browserswitchpippphilipp10/01/01 13:30
Implementationruusvuu10/01/01 09:47
RE: Sniffer codeMark09/28/01 08:26
Sniffer codeLoki09/12/01 03:39
RE: Form fieldskutte09/11/01 02:01
RE: My own PHP browser detectionToma08/30/01 08:39
CSS PositionThomas08/17/01 11:33
RE: Netscape and style-classesJoel Sanda08/03/01 22:57
How to check about bit-encription of browser?prinya07/26/01 20:27
How to check bit encription of browser?Pim07/26/01 20:10
RE: Netscape and style-classesalex07/19/01 05:02
Netscape and linked CSS's the answer!!noboby important07/10/01 06:48
Help PleaseAnthony P Bikowski07/08/01 13:55
What is formal specification TechniquesPujari Pandit07/06/01 07:19
xx-small and TEXTAREAHenrik Erlandsson07/04/01 09:18
Netscape and style-classesErx06/24/01 12:57
RE: Can Anyone Know how to do this?Just Some Guy06/23/01 20:46
RE: simpler: generating external CSS with php.Eric Blade05/30/01 00:20
Can Anyone Know how to do this?GamerZ05/28/01 00:13
RE: Forget all that code *sheesh* do thisDan05/25/01 00:55
RE: simpler: generating external CSS with php.Servo05/23/01 13:22
RE: Use pixels in CSSServo05/23/01 13:05
RE: Forget all that code *sheesh* do thisServo05/23/01 12:52
RE: Forget all that code *sheesh* do thistenacious04/20/01 02:21
Opening new windowC. Dick04/13/01 17:51
Neater way for the final stepDave04/10/01 05:17
RE: Mozilla?FlyHigh04/02/01 14:01
RE: simpler: generating external CSS with php.FlyHigh04/02/01 13:55
RE: Mozilla?Eric Blade03/26/01 13:14
RE: simpler: generating external CSS with php.Eric Blade03/26/01 13:08
simpler: generating external CSS with php.Ben Hardy03/12/01 14:52
Forget all that code *sheesh* do thisMike Webby03/11/01 18:21
yikes, my bad (was: other options)adam02/17/01 19:50
RE: How get the client screen size?Colin Bell02/03/01 07:39
How to position multiple layers?aumbrother01/27/01 16:21
other options...adam01/21/01 07:28
RE: Using it to link external style sheetsMichael Svazas01/19/01 20:22
The (in)famous CSS trickSimen Brekken01/11/01 04:55
RE: Won't work, no matter whatDonny01/09/01 18:32
RE: How get the client screen size?Liam DelaHunty01/06/01 16:48
How get the client screen size?Farrukh Shahzad12/26/00 09:45
RE: My own PHP browser detectionRick Allen12/06/00 16:56
Won't work, no matter whatRick Allen12/05/00 17:17
RE: Using it to link external style sheetsAndrew11/27/00 21:56
PHPClientSnifferRoger Raymond11/03/00 16:03
RE: Mozilla?Joseph M. Ferris10/24/00 18:33
RE: My own PHP browser detectionNeil P Davis10/19/00 08:44
RE: version returs 0 and agent returns OTHERNeil P Davis10/19/00 08:40
RE: Browsers so poorly with CSSNeil P Davis10/18/00 15:47
RE: Code breaks on resizing window in NetscapeSean Wilson10/15/00 19:37
javascript:history.back()Philip10/09/00 01:20
Code breaks on resizing window in NetscapeJeanie MacWilliam10/04/00 16:27
RE: Browsers so poorly with CSSKyle Donaldson09/27/00 11:23
RE: version returs 0 and agent returns OTHERKyle Donaldson09/26/00 19:31
YABC- yet another browser checker :)dbrossa09/11/00 16:12
RE: Why css_site()?philip olson09/11/00 12:00
Why css_site()?Anders Mejner09/09/00 14:49
Windows BrowsersJames08/30/00 16:01
version returs 0 and agent returns OTHERDanny Appaiah.M.M08/30/00 02:01
My own PHP browser detectionAlex Lee08/30/00 00:42
RE: Mozilla?Alex Lee08/30/00 00:37
Use pixels in CSSVladimir Rüntü08/29/00 05:13
RE: Using it to link external style sheetsJeremy Rempel08/27/00 21:49
RE: Form fieldsDELCAMPE Sébastien08/27/00 03:26
Using it to link external style sheetsEvert Smit08/25/00 04:26
RE: AwesomeBrett Stimmerman08/25/00 01:20
RE: AwesomeAmaury Jacquot08/24/00 23:55
RE: Mozilla?Richard Heyes08/24/00 15:10
mozilla vs. netscape renderingTodd Hammer08/24/00 13:54
RE: Need AssistanceWolfgang Drews08/24/00 08:58
RE: Form fieldsPeter Huestis08/24/00 07:31
Form fieldsDELCAMPE Sébastien08/24/00 02:12
RE: Mozilla?philip olson08/23/00 20:28
Mozilla?Neil Moomey08/23/00 20:10
RE: Browsers so poorly with CSSPeter Huestis08/23/00 17:57
Browsers so poorly with CSSRyan McGeary08/23/00 17:05
RE: Awesomejim08/23/00 04:42
Need AssistanceChris Carroll08/23/00 02:18
RE: AwesomeRichard Heyes08/22/00 13:53
AwesomeBrett Stimmerman08/22/00 02:40
RE: Why not get_browser() ?Peter Huestis08/21/00 12:50
get_browser..Chad Day08/21/00 10:49
RE: Why not get_browser() ?Tim Perdue, PHPBuilder.com08/21/00 10:34
Why not get_browser() ?Jens-Petter Salvesen08/21/00 10:18
Getting this Implemented Now...Peter Huestis08/21/00 09:13
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.