Home arrow PHP arrow Page 2 - PHP Browser Detection and Appropriate CSS Generation

PHP Browser Detection and Appropriate CSS Generation

In this article, Tim explains his browser detection utility and how you can use it to generate the right CSS for each user.

Author Info:
By: Tim Perdue
Rating: 4 stars4 stars4 stars4 stars4 stars / 45
February 16, 2003
  1. · PHP Browser Detection and Appropriate CSS Generation
  2. · CSS Tips
  3. · Browser Detection Library
  4. · Font Size
  5. · Conclusion

print this article

PHP Browser Detection and Appropriate CSS Generation - CSS Tips
(Page 2 of 5 )

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.
blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials