Saturday, February 05, 2005

Introduction to Browser-Specific CSS Hacks

By Trenton Moss

“More and more Web developers are ditching tables and coming round to the idea of using CSS to control the layouts of sites. And, given the many benefits of using CSS, such as quicker download time, improved accessibility and easier site management, why not?

The Problem with CSS

Historically, the main problem with using CSS has been a lack of browser support. This is no longer the case, as version 5 browsers, which all provide good support for CSS, now account for over 99% of the browsers in use.

The problem that remains is that browsers can sometimes interpret CSS commands in different ways, which fact alone causes many developers to throw their arms up in the air and switch back to pixel-perfect table layouts. Fear not, though! As you learn more about CSS, you'll gradually start to understand the different browser interpretations and realise that there aren't really that many -- and that, where necessary, their idiosyncrasies can be catered to using various workarounds or hacks.

How CSS Hacks Work

The way CSS hacks works is to send one CSS rule to the browser(s) you're trying to trick, and a second CSS rule that overrides the first command to the other browsers. If you have two CSS rules with identical selectors, the second CSS rule will almost always take precedence.

http://www.sitepoint.com/article/browser-specific-css-hacks

No comments: