I have a habit of using one or two IE conditional styles in my sites as it greately speeds up my development time. I am not comfortable however putting any styles in the header of my pages but I can't figure out the syntax to put them in my style sheet. Can someone show me how to do this? I would greatly appreciate it. Sincerely, Artdog
You can't put them directly in the stylesheet itself. What you need to do is create one "standards compliant" stylesheet with the styles you want all browsers to see, then an "IE only" stylesheet that overrides those set in the other stylesheet containing workarounds for IE. Then, what you do is: <link rel="stylesheet" type="text/css" href="standard.css"> <!--[if IE]> <link rel="stylesheet" type="text/css" href="ie.css"> <![endif]--> Code (markup): This works because of the cascade - the lower stylesheet overrides any stylesheets that come before it. Hope that helps
I also found that ie7 is more compliant, so to address older versions of ie you can use this <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" charset="utf-8" href="ie.css" media="screen" /> <![endif]--> Code (markup):
That's not exactly a ringing endorsement. Besides being a non-standard proprietary method, it separates the IE specific hack from the standard selector/property. That makes maintenance and debugging more difficult. The conditional comment is a truly ugly hack; one to be avoided if at all possible. If you just must use it, plan well. Keep the IE hacks in the same order as the original standard stylesheet, and be sure to add comments that explain and point to the original standard selector and property. The standard selector should also have a comment that points to the hack. Code and comment as if the person who will maintain the document is a violent psychotic who knows where you live. cheers, gary
Thanks guys for the help. I am a "If it works its ok with me" kind of guy and anything that can speed my development and prevent my clients complaining about over billing works for me.