Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE conditional comments to target ie9/ie10 and non-ie browser #1002

Closed
yogoo opened this issue Feb 28, 2012 · 10 comments
Closed

IE conditional comments to target ie9/ie10 and non-ie browser #1002

yogoo opened this issue Feb 28, 2012 · 10 comments

Comments

@yogoo
Copy link

yogoo commented Feb 28, 2012

Consider adding a conditional comment to target ie9, ie10 and non ie-browser :

<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if IE 9]>    <html class="no-js lt-ie10" lang="en"> <![endif]-->
<!-- Consider adding a manifest.appcache: h5bp.com/d/Offline -->
<!--[if gt IE 9]><!--> <html class="no-js gt-ie9 non-ie" lang="en"> <!--<![endif]-->

This allows to differentiate ie9 from browsers that offer a better support of html5/css3 (ie10, chrome, FF, safari) and to write rules that should never be applied when the browser is Internet Explorer.

I just needed that on site's form for graceful degradation of the placeholder attribute without using any javascript.
This allows to hide form labels and use placeholder where supported (ie10, chrome, FF, saf.) and to show labels where placeholders are not supported (ie9 and below).

@thisispvb
Copy link
Contributor

We already had this, but it has been removed in #142 because IE9 is not so bad compared to it's predecessors.

@yanneves
Copy link

I think I read in the documentation that there was an issue in having so many conditional statements like this. It's always worth customising these for any particular project, e.g. if you're only targeting IE8+, why bother with IE7 or IE6 tags.

If you're targeting IE9+, perhaps swap some of these round. I think there's a limit to the number of conditionals that can be included by default to avoid a compatibility mode icon being presented in the address bar.

@alilleybrinker
Copy link

@Aaunel can't you simply avoid triggering compatibility mode with the following meta tag?

<meta http-equiv="X-UA-Compatible" content="IE=edge">

Based on that, assuming there's no substantive increase in load times, and it doesn't introduce some other bug, what is the downside to including an additional conditional statement at the top of the document?

Even though IE9 is good, there are still things it doesn't do perfectly, and using conditionally-assigned classes instead of browser hacks seems like a good idea.

@lhwparis
Copy link

lhwparis commented Mar 1, 2012

ie9 is not that bad. i dont think we need a conditional command for ie9 or ie10.

@yanneves
Copy link

yanneves commented Mar 1, 2012

@AndrewBrinker short answer: no... A series of cc's forces IE into rendering the page in compatibility mode and ignoring the edge-case in meta. The workaround for Apache users is to include the edge-case in .htaccess. Worth referring to h5bp.com/i/378 and zachleat.com/web/et-tu-x-ua-compatible.

If anything, I think the cc's should be entirely reduced to lt-ie8 and lt-ie9 by default. Look at css-tricks.com in IE7; providing simplified lt-ie8 styles (e.g. replicating print styles) could be a good way forward.

So...

<!--[if lt IE 8]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

IE9 seems to be adapting reasonably well so far, and anything that's not supported is handled best using modernizr.

@yogoo
Copy link
Author

yogoo commented Mar 1, 2012

As I understand it, h5bp is made as a starting point and provides useful tips and optimizations. It needs to be adapted to every project's need and conditional comments were made to make developers' life easier.

If h5bp still accounts for ie6, why not account for ie9 specificities? No betrayal there, but the simple recognition that as you say « it's not so bad ». As pointed out in the article cited in #142, ie9 came a long way forward but didn't catch up yet.

There are still edge cases and some of them can be adressed without javascript. So the Modernirz approach recommended in #142 isn't convincing.

Overall it falls down to performance and conversion. Why add the overload of javascript libraries and polyfills when it can be done with conditional comments + a few lines of css. I mean: http request, load time, processing, DOM modifications...

@lhwparis
Copy link

lhwparis commented Mar 1, 2012

the class set with conditional commands should be used to fix bugs in older ie versions. ie9 has fixed most of this bugs so no need for such a class. features not available in IE9 like css-gradients should never be adressed with the help of this class! use modernizers feature detection instead!

@yanneves
Copy link

yanneves commented Mar 1, 2012

@yogoo if you're already using Modernizr there's no significant additional processing time... there would, however, be additional time involved in writing a CSS workaround, plus potential room for error where your own solution may incur other issues... crowd-source the polyfillers, it's what plugins like Modernizr are available for

@lhwparis also, you're spot-on in that feature detection > browser detection

I find the conditional comments pretty ugly, but certainly agree that they're the best solution amongst alternatives.

@yogoo
Copy link
Author

yogoo commented Mar 1, 2012

Makes a lot more sense. Especially the part on conditional comments made for bug correction. Thanks for the explanations.
I still don't like the idea of loading Modernizr per default but I can live with that ;)

@yogoo yogoo closed this as completed Mar 1, 2012
@Johnny5k
Copy link

Since IE10 doesn't recognize any conditional comments, <!--[if gt IE 9]> actually means the same thing to it as <!--[if !IE]>. So shouldn't it be changed to <!--[if !IE]> now that we know that? Or will that confuse developers who think that means (logically) that it's not going to target IE10? So it's either support the correct way that's confusing, or continue to support the old way that's more logically correct, but is actually meaningless...

Leave it to Microsoft to make a statement as simple as [if !IE] not exclude all versions of IE. (I get why they're getting rid of conditional comments; it's just going to be a weird transitional period -- and I can't imagine there won't be SOMETHING we'll still need to detect IE10 for)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants