ArticlesReader.com Menu
Newest Articles
Most Viewed Articles
ArticlesReader.com RSS
Submit Article
Login
Signup
Search the articles

Articles Main Categories
Advice
Animals
Automobiles
Business
Career
Communications
Computer Programming
Computers
Entertainment
Environment
Family
Fashion
Finance
Food
Health & Medical
Home & Garden
Humor
Internet Business
Internet Marketing
Legal
Leisure & Recreation
Marketing
Other
Politics
Reference & Education
Religion
Self Improvement
Sports
Technology & Science
Travel
Writing
Subscribe
Receive alert message from us when new articles submitted to our site for free.

Enter your name

Enter your email

Syndicate

















Related Products
Home::Cliff Ritter

CSS Browser Detection - The complete guide

Author : Afonso Ferreira Gomes

Different browsers, different CSS interpretations! There will
be a time when you'll need to hide some CSS rules from a
particular browser, or even all the CSS file! In this articles
I'll try to compile all possible types of Browser detection
technics and provide examples. So let's start with the easier
one!

Browser detection for Netscape

Netscape 4 is probably the dumbest browser when it comes to CSS
support, extremely limited and many times erroneous! As the
browser's market share of Netscape is below 0.5% it became
natural to hide the CSS file from it! The method used for this
is the import directive that will make the browser to display a
version of the site completely without CSS.

Here's the directive you have to call: (style
type="text/css")@import url(wise-designscom.css);(/style)

Browser Detection for IE Mac computers

This browser "died" when Microsoft announced there would be no
more updated versions of it. Now this browser fell in desuse and
there are a wide range of CSS technics that IE/Mac doesn't
interpret well! Therefore many webmasters started to code their
CSS sites so that they would work correctly on this browsers.
Contrary to Netscape users, these weren't neglected.

The hide technic:

/* Hide from IE-Mac */ #header {padding-bottom:3em} #footer
{padding-top:1.5em} /* End hide */

IE/Mac won't see these commands but will display the content
even without those rules! Now... if you have a specific area of
your site that isn't vital to your visitors you can just hide it
completely from this browser without having the trouble to even
try and make it look better within the possible! Here's how:

#noiemac {display: none}

/* Hide from IE-Mac */ #noiemac {display: block} /* End hide */

The first rule hides it all from IE/Mac (e.g id="noiemac">content to hide here!)

The second CSS ruledisplays the section cause Ie/Mac can't see
it!

Browser Detection for Internet Explorer

For this one we'll have to use the "child selector". This rule
consists of two elements, the parent and his child! Let it be
html>body, body being the child of html the parent! As IE don't
understand it, it will come a time when this knowledge will come
to be handy!

The typical example of the header margin:

#header {margin-bottom:4em} html>body #header {margin-bottom:1em}

IE will use the 1st rule cause it's blind to the 2nd and all
other browsers will use the 2nd one!

Browser Detection for Internet Explorer 5

At first this one was strange to me! How the hell we have to set
different rules for different VERSIONS of the same browser?
Well, the truth is that IE5 doesn't get right the box model!
When we specify the width of an element in CSS, that doesn't
include the values of padding and borders. IE5 include these
values in the width, which leads to widths become smaller in it!

Let's see the following example:

#header {padding: 2em; border: 1em; width: 12em}

For all browsers this width would be 12em! For IEe the width
would be 6em!! God! How is that possible? Simple: 12em (Width) -
4 (padding left + padding right) - 2 (border left + border
right)!

Is there any solution for this problem? Sure! A clever guy,
named Tantek Ēelik (you'll hear of him a lot if you read many
tutorials of CSS! This is kind of the most important discovery
since the wheel on CSS community!) invented the box model hack

He said that to make browser detection work , and send a
different CSS rule to IE5 you would use the following:

#header {padding: 3em; border: 1em; width: 18em; voice-family:
""}""; voice-family:inherit; width: 12em}

IE5 will use the first width value of 18em! 6em of which will be
taken up by the padding-left + padding-right + border-left +
border-right. This would ultimately give the element a width of
12em in IE5.

The 18em value will then be overridden by the second width value
of 12em by all browsers except IE5, which, for some reason,
can't understand the CSS command that comes immediately after
all those squiggles. It doesn't look pretty, but it does work!

I hope this articled helped you understand the different
situations related to browser detection in the CSS world! At
first it was confusing to me but with 2/3 hours of reading
anyone would be able to understand this ... and understand well!
For more quality articles and tutorials please visit my site at
http://www.wise-designs.com ! I'll be expecting you there!!

Spam emails More free articles

Related articles


  1. Introduction To Cascading Style Sheets
  2. CSS: The Basics - ID's and Classes
  3. CSS: The Basics - ID's and Classes ... Correct
  4. CSS - Maximum benefits
  5. Using CCS to Eliminate Tables
  6. CSS Print Media Tutorial
  7. Teach yourself CSS the easy way
  8. Starting Cascading Style Sheets
  9. SEO Benefits Of CSS
  10. 7 Reasons Why Using CSS is a Must
  11. Font Organizers Review, Part I
  12. CSS in Flash the return of crisp and legible fonts.
  13. CSS Browser Detection - The complete guide
  14. Cascading Stylesheets: 5 Reasons To Use CSS
  15. The Power of CSS
  16. Cross Browser Compatibility
  17. Using CSS with Tables
More related feeds
CSS Browser Detection - The complete guide
There will be a time when you’ll need to hide some CSS rules from a particular browser, or even all the CSS file! In this articles I’ll try to compile all possible types of Browser detection technics and provide examples. ...

Identifying NoFollow Links Using Firefox | Malditang Pinay
This step by step guide will show you how to modify the userContent.css file to show the rel=”nofollow” links highlighted in red. How to detect the attribute rel=”nofollow” using the Firefox browser: ...

~BLACKBERRY~ CLICK HERE | HTC Wizard Web
cingular blackberry browser guide recipe for blackberry cobbler blackberry margarita recipe blackberry 7100i reviews blackberry compatible media players javascript for blackberry 8830 blackberry planting blackberries ...

Internet Explorer 7 Browser and Small Business Websites | google ...
In conclusion, the new version IE7 browser has been announced with a variety of key benefits including improved security and enhanced support of CSS, Cascading Style Sheets. CSS is a technique used by some website designers for improved ...

Script Fragmentation Attack Could Allow Hackers to Dodge Anti ...
Ubuntu Security Notice USN-676-1 - It was discovered that WebKit did not properly handle Cascading Style Sheets (CSS) import statements. If a user were tricked into opening a malicious website, an attacker could cause a browser crash ...

Detect Mobile Devices - Detect Cell Phones - Detect PDAs
They want to use some type of browser detection script to detect if the customer is on a mobile device and then redirect them to the mobile site. The problem with browser detection and mobile devices is that there are thousands of ...

HOW TO: A Web Standards Checklist, How to make a proper website
http://css.maxdesign.com.au/listamatic/about-boxmodel.htm CODE http://gutfeldt.ch/matthias/articles/doctypeswitch.html 1.2 Does the site use a Character set? If a user agent (eg. a browser) is unable to detect the character encoding ...

Handling Remote Files with JavaScript Click Interceptions
Protecting the Server Ā· - Book Review: Learning the Yahoo! User Interf... - Dynamically Generate a Selection List in a R... - Intergrate DWR into Your Java Web Application Ā· - Detect Browser Compatibility with the Reques. ...

css chrome fix + load ads after html by ntpk | FreeLance Home Jobs
javascript to detect browser language and load one URL for English, another URL for Spanish. Must wrk with IE, Firefox, Safari and Chrome. Keywords:Web,Other (Web)Place Your Bid Post similar project ...

<li> margins seem to be huge in Safari? - bytes
well, for posterity, my css looks like this (ignore lazy php browser-detection function):. Expand|Select|Wrap|Line Numbers. ; ul {; margin: 0px;; padding: 0px;; list-style-type: none;; border: 0px solid black;;

 


 

© 2007 articlesreader.com - All Rights Reserved