Pages
Friends
Recent Posts
- Paging in PHP – PHP Paging Tutorial
- HostGator Discount Code 2010 – Cheap Web Hosting
- ING Direct Orange Key 2010
- Hide Google Custom Search Engine (CSE) Textbox
- High Rate Interest Account – Tax Free Accounts Canada
Buy me a Beer!
Categories
- ASP.NET
- C#
- Cheap Hosting
- Databases
- Finance/Investing
- General
- Javascript
- MySQL
- PC Maintenance
- PHP
- Programming
- SEO/Marketing
- SQL
- Uncategorized
- XHTML/CSS
Archives
Tags
advertising
backup
batch tips
batch tricks
batch utitilities
beginner css
C#
centering a container in ie
centering a div in ie
centering a wrapper in ie
centering in ie
change javascript alert button
change javascript alerts
change javascript button text
change javascript confirm button text
conditional comments
cross browser css
cross browser css fixes
c sharp
css
css design
css fixes
css hacks
css layout
css techniques
css tricks
custom dialog boxes
custom javascript alerts
custom javascript dialog boxes
custom php paging
development
easy javascript validation
easy jquery validation
fixing ie css
General
html
ie css
marketing
Programming
search engine optimization
SEO/Marketing
seo tools
tableless design
tableless layout
XHTML
CSS Cross Browser Compatibility – Conditional Comments/CSS Hacks
CSS Hacks/Conditional Comments
This is going to be a short/quick article. Straight to the point.
The lack of Cross browser support for CSS2 is horrible. CSS3 will soon be standard and implemented across many newer browsers, but until then here are a few suggestions on targeting different browsers.
Using a global reset.css is important, this resets a lot of the properties which may be different across browsers and gives you a good baseline starting point. A global reset can iron out many browser inconsistencies.
CSS Reset.css
This was taken from http://stylizedweb.com/2008/02/14/10-best-css-hacks/
Conditional Comments
Conditional comments
Implemented by IE to fix their retarded browsers, conditional comments can help you target different versions of IE.
CSS Hacks
There are many CSS hacks. However, these are the couple I find most useful.
Star-property Hack
*property: value;
Not sure on the name but I call this the star-property hack. This hack allows you to target IE7 and below.
Underscore-property Hack
_property: value;
This targets IE6 and below. Any styles will be applied to ie 6 and below.
!important Targetting
The !important at the end of a style, tells browsers that this property should override any other declarations of that property regardless of position. For example in this case:
width: 10px !important;
width: 80px;
Even though the 80px declaration comes second, Firefox 3 and IE7/8 will render this style as 10pixels. IE6 does not recognize the !important declaration and will apply an 80pixel width.
I prefer this method when I need to target IE7 and FF with one rule, and IE6 with the other. This is a valid method of feeding one rule to ie7/ff and another for ie6.
CSS Examples
div.test{
margin-top: 10px; //firefox
*margin-top: 15px; //ie7
}
div.test{
margin-top: 10px; //firefox
*margin-top: 5px; //ie7
_margin-top: 2px; //ie6
}
div.test{
margin-top: 10px !important; //ff and ie7
mragin-top: 2px; //ie6
}
NOTE: The star property hack and the underscore property hack are NOT valid css, but sometimes you need to get a little dirty to fix IE7 and IE6 issues. With the release of IE8, hopefully the inconsistencies of cross browser css will finally be ironed out, however people will still insist on using IE7...so knowing how to support it is important.
Hope you enjoyed.