Previous Message
Next Message

IE7, future browsers, hack strategies

Sent by Ben Curtis on 4 August 2005 19:07


>> i've read somewhere that many IE CSS deficiencies won't be  
>> addressed in
>> the new IE release at all. Is this really so bad?
>> I don't want to see all those pages looking bad in the new IE just
>> because Microsoft suddenly decided to apply to standards and all  
>> those
>> old IE-hacks behave awkward now.
....
> There are no public releases of what is supposed to be called 'IE  
> 7', hence it is pretty pointless to argue about what it will do. Or  
> not do. Or might attempt to do.

Right. There are valid strategies to employ, although prediction is  
not one of them.

The best strategy I use is: "Only hack the dead."

Some Dead Browsers: Mac IE, Win IE 4-6, Netscape 4-6, Opera 7

Any hacking, delivered to dead browsers in such a way that a  
compliant browser with the same feature list will not see the hacks,  
ought to be fine. The bugs are known, and the targeting is likely to  
be good for life. Assume non-dead browsers are compliant and don't  
need hacks until proven differently.

If your hacks target via a bug (e.g., the Mac IE comment-parsing  
bug), it is unlikely to accidentally target a future browser that is  
not susceptible to it today. If you target via a feature (e.g.,  
conditional comments, javascript, etc.), and you properly use that  
feature to shield future browsers that implement it, then you are  
unlikely to accidentally target a future browser with or without the  
feature.

On my team, we currently use the following, included on every page  
via server-side parsing:

     <link rel="stylesheet" type="text/css" href="/css/merged.css"  
media="all" />

   <!-- style hacks to bring specific browsers in line with standards  
-->
     <style type="text/css">/*\*//*/@import url("/css/hacks/ 
mac_ie.css");/**/</style>
     <!--[if lt IE 7]>
         <link href="/css/hacks/win_ie.css" rel="stylesheet"  
type="text/css" media="all" />
     <![endif]-->

The "merged.css" in this case only has compliant code, no hacks, and  
no workarounds. It's also 95% of the CSS on the site; we have a  
script that dynamically combines, compresses, and caches a variety of  
other sheets which serve specific purposes (big sites may have  
layout, look, forms, in-page structures, etc.), and thus the name  
"merged."

The mac_ie.css only goes to Mac IE, and contains none of the hacks  
that apply to that browser but only clean CSS that would apply to any  
browser -- but only Mac IE sees it.

The win_ie.css sheet goes to Windows IE5, 5.5, and 6. Because of our  
policy to not use a browser's quirks mode (we need some  
consistency!), this means that within the win_ie.css sheet we need to  
deliver different box models to IE 5.x and IE 6. We achieve this with  
the mid-property escape hack:

     width:40em; /* all win IE */
     w\idth:38em; /* IE 6 */

We used to use JavaScript to give Safari a little help with min- 
height, but in the end only needed it so rarely that we found other  
hackless ways.

We are now contemplating introducing a "/css/hacks/workarounds.css"  
that will be delivered to all browsers. This will help us address IE  
7 problems by using compliant code and no hacks (because IE 7 is not  
dead), while keeping the main sheet using css "as intended." No hacks  
allowed in here, just creative bend-over-backwards CSS (e.g., using a  
background image if the content property is not supported in IE7).

If they release an IE 7.1, then we'll adjust our conditional comment  
to accept 7.0 and treat 7.0 as Dead. It now gets hacked in the  
win_ie.css sheet.

Within the hack stylesheets, which are only targeted to dead  
browsers, hacks are ok because the hacks are stable. But in the main  
stylesheets, all hacks are forbidden. We used to use "* html" but  
this comment[1] makes it look like MS is starting to consider this a  
"feature" (due to the clamor of the CSS authors), but since it can't  
be used to filter out future versions that use the feature, it's not  
a Good Hack.

---------

1. http://blogs.msdn.com/ie/archive/2005/07/29/445242.aspx#445550

-- 

     Ben Curtis : webwright
     bivia : a personal web studio
     http://www.bivia.com
     v: (818) 507-6613




______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message