Quote:
Originally Posted by PaulClark
Whether or not you'd advocate using conditional comments, it remains the correct way to target specific styles at IE6/7, recommended by Microsoft for exactly that purpose. (See MSDN Article on Conditional Comments.)
The two most common strategies are to 'hide' a call to an additional external stylesheet within the conditional comment or, as I prefer to do, to use conditional comments to wrap an additional named DIV around your whole HTML page if the browser is IE, and then target tweaks using dependent selectors.
Regarding creating sites that work cross-browser without specific browser targeting, this is possible for some basic sites, but as soon as you get more sophisticated it is impossible. Reasons for this include: - IE6 interprets the box model differently to other browsers. As such, if you are doing pixel perfect layout using padding, borders and margin you HAVE TO provide different dimensions to IE.
- IE6 does not recognise min-width and min-height. It also interprets 'height' as other browsers interpret min-height. In complex designs, you will frequently need to set min-height on a DIV, then set height for IE6. You can not just set height for all browsers, as Firefox etc will interpret this as a fixed value and truncate your content if it overflows.
- Certain effects can only be created in IE using microsoft-specific directives. Opacity is a good example. If you put microsoft-specific directives in your general CSS, it won't validate.
|
There are ways around these issues just using css. The sites I build range from sme sites to large publisher websites and I've never had to use any conditional statements or CSS hacks.
i.e if you want to add padding to a fixed width div you can simply place a div inside the one with the fixed width and add padding to that...
When I started in my current job they were using multiple stylesheets for all their sites so that they could target browsers. They now just use the one stylesheet as they now realise you can build pixel perfect cross browser sites without the need to conditional statements etc.