universal IE stylesheet, dashes in conditional comments
This is an open discussion with 11 replies, filed under General.
Search
<xsl:comment><![CDATA[[if IE 6]><link rel="stylesheet" type="text/css" href="]]><xsl:value-of select="$root"/><![CDATA[/workspace/assets/css/ie6.css" media="screen" /><![endif]]]></xsl:comment>
@designermonkey
Thats just to serve ie.css to ie.
To clarify, I want to hide the other stylesheet from IE6, like this;
<!--[if ! lte IE 6]><!--> /* Stylesheets for browsers other than Internet Explorer 6 */ <!--<![endif]-->
There is no way to get the additional <!-->
and <!--
inside a xslt comment… unless…
http://www.xml.com/pub/a/2000/09/13/xslt/index.html
I don’t understand why you would want the extra and <!—
Using conditional comments the same way, but changing your condition should do the trick as you require..
Oh, hang on now I understand, it would be a comment to all other browsers otherwise…
I didn’t realise how hard it was to do this, I assumed it would be possible. That’s got me thinking for my own project now…
Maybe this would help, although it is ugly hacks in your CSS
@newnomad
If I am understanding you correctly, I think this is what you are looking for:
<xsl:comment>[if gt IE 6]<![CDATA[><!]]></xsl:comment> <link type="text/css" rel="stylesheet" href="{$workspace}/stylesheets/site.css" /> <xsl:comment><![CDATA[<!]]>[endif]</xsl:comment>
It will hide the CSS from any version of IE below 7, but let any version of Safari, Opera, Firefox, etc. see the file. Took me quite a bit of experimentation to figure this one out. It will produce:
<!--[if gt IE 6]><!--> <link type="text/css" rel="stylesheet" href="http://www.url.com/workspace/stylesheets/home.css"/> <!--<![endif]-->
Great! Indeed quite some experiments, mine had failed before folowing this route, but you nailed it!
I never thought about it that way! Brilliant!
I would still technically consider this a hack, but I think at this point it’s the best option of many evils.
what XSL hero could get the Conditional Comment trick from HTML5boilerplate.com to work?
The tricky part seems the very last statement (not IE OR greater than IE9): this needs comments in comments in comments :-/
I got the first part, which seems to boil down to:
<xsl:comment><![CDATA[[if lt IE 7]><body class="ie ie6 lte9 lte8 lte7"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE 7]><body class="ie ie7 lte9 lte8 lte7"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE 8]><body class="ie ie8 lte9 lte8"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE 9]><body class="ie ie9 lte9"><![endif]]]></xsl:comment>
Now the only thing added needs to be: <!--[if (gt IE 9)|!(IE)]><!--> <body> <!--<![endif]-->
@davidhund -
Try this…
<xsl:comment><![CDATA[[if lt IE 7]><body class="ie ie6 lte9 lte8 lte7"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE 7]><body class="ie ie7 lte9 lte8 lte7"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE 8]><body class="ie ie8 lte9 lte8"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE 9]><body class="ie ie9 lte9"><![endif]]]></xsl:comment> <xsl:comment><![CDATA[[if IE]><![if (gt IE 9)|!(IE)]><![endif]]]></xsl:comment><body> <xsl:comment><![CDATA[[if IE]><![endif]><![endif]]]></xsl:comment>
Hmmm the above threw errors for me, but this seemed to work:
<xsl:comment><![CDATA[[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]]]></xsl:comment>
<![CDATA[[if IE 7]> <![endif]]]><![CDATA[[if IE 8]> <![endif]]]>[if (gte IE 9)|!(IE)]<![CDATA[><!]]><![CDATA[<!]]>[endif]
<xsl:comment>[if (gte IE 9)|!(IE)]<![CDATA[><!]]></xsl:comment><html class="no-js" lang="en"><xsl:comment><![CDATA[<!]]>[endif]</xsl:comment>
Create an account or sign in to comment.
In order to use IE universal stylesheet one should put extra dashes inside
xsl:comment
which isn’t possible. (not even withCDATA
, or<xsl:text disable-output-escaping="yes">
)How to hide the IE6 only stylesheet from other browsers?