IE Conditional statement not parsing correctly in DNN (dotnetnuke) - css

I am using three conditional CSS files in my site, one for ie7, one for ie8 and one for IE only. IE7 and 8 are parsing properly when I parse the skin but for some reason, IE only conditional does not want to parse correctly, leaving this when the browser renders
<!--[if]> <![endif]-->
If however, I add that conditional statement directly to the parsed ascx page, the conditional works properly.
Here are the three conditional statements:
<!--[if IE]>
<link href="/portals/0/skins/sunmedia2011/css/97iefixes.css" rel="stylesheet"
type="text/css">
<![endif]-->
<!--[if IE 7]>
<link href="/portals/0/skins/sunmedia2011/css/98ie7fixes.css" rel="stylesheet"
type="text/css">
<![endif]-->
<!--[if IE 8]>
<link href="/portals/0/skins/sunmedia2011/css/99ie8fixes.css" rel="stylesheet"
type="text/css">
<![endif]-->
Any thoughts?
Thanks!

I know this is old but could be helpful to someone:
<!--[if IE]>
<link href="<%= SkinPath %>css/97iefixes.css" rel="stylesheet"
type="text/css">
<![endif]-->
<!--[if IE 7]>
<link href="<%= SkinPath %>css/98ie7fixes.css" rel="stylesheet"
type="text/css">
<![endif]-->
<!--[if IE 8]>
<link href="<%= SkinPath %>css/99ie8fixes.css" rel="stylesheet"
type="text/css">
<![endif]-->

Related

Basic conditional statement in IE

I have three stylesheets; one for IE7, one for IE8 and one for IE9+ / Firefox / Chrome.
I want to use conditional statements to link each of these to my document. I have written these statements:
<!--[if IE 8]>
<link type="text/css" href="ie8.css" rel="stylesheet"/>
<![endif]-->
<!--[if IE 7]>
<link type="text/css" href="ie7.css" rel="stylesheet"/>
<![endif]-->
<!--[if ?????]>
<link type="text/css" href="style.css" rel="stylesheet"/>
<![endif]-->
I am unsure of what to write in the if statement of the final conditional. I need something like:
<!--[if IE 9+ | !IE>
Which would mean IF IE9+ or NOT IE.
Is this achievable using conditionals?
Found the answer:
<!--[if IE 8]>
// ie 8 stuff
<![endif]-->
<!--[if IE 7]>
// ie 7 stuff
<![endif]-->
<!--[if !(IE)]><!--> i am not ie <!--<![endif]-->
<!--[if gt IE 8]>
<link rel="stylesheet" type="text/css" href="ie9-and-up.css" />
<![endif]-->
<!--[if gte IE 9]>
<link rel="stylesheet" type="text/css" href="ie9-and-up.css" />
<![endif]-->
gt means "greater than", gte means "greater than or equal".
Edit
from IE Conditional operator: OR ... if is greater than ie9 or not IE
<!--[if gte IE 9 | !IE ]><!-->
<link rel="stylesheet" type="text/css" href="ie9-and-up.css" />
<![endif]-->

Conditional load css for IE6

Why is this ie6.css file not loading on IE6?
The 'TEST 123' text does show.
(the css works if I remove the condition)
I'm testing this on a virtual box with xp and IE6 from http://modern.ie
(I know the _ and * css hacks, but I need a very different layout on IE6)
<!DOCTYPE html>
<html>
<head>
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="~/Web/css/ie6.css" />
<![endif]-->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CE Client</title>
</head>
<body>
<!--[if lt IE 7]>
<p>TEST 123</p>
<![endif]-->
</body>
</html>
You have to use the full url.
When using the syntax like that it won't work in your browser.
"http://yourwebsite.com/Web/css/ie6.css"
You should be able to use:
Target IE 7 and LOWER
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="~/Web/css/ie6.css" />
<![endif]-->
OR
Target IE 6 ONLY
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="~/Web/css/ie6.css" />
<![endif]-->

IE comment not rendering css on the page at all

This is my website, it works fine on chrome, firefox and IE 9. When i try it on IE 7 & IE 8 the IE comments that I use for css is not showing at all. My website: http://www.chan-leung.com
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ieHacks.css" type="text/css" media="screen, projection" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="css/ieHacks7.css" type="text/css" media="screen, projection" />
<![endif]-->
The css files works fine locally, but when i upload to my hosting, the css doesn't show. I'm using IE debugger for browser testing (for IE). The F12 key for IE. When i try to look up ieHacks.css & ieHacks7.css, nothing is showing. I'm stump as to what would be the reason why the ie comments is not working.
Any help or suggestion would be greatly appreciated.
Perhaps you have names the css files incorrectly?
You site is maybe trying to use css/ieHacks.css and css/ieHacks7.css but the actual files are css/iehacks.css and css/iehacks7.css
Also try using absolute urls and see if it makes a difference e.g:
<!--[if lt IE 9]>
<link rel="stylesheet" href="/css/iehacks.css" type="text/css" media="screen, projection" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="/css/iehacks7.css" type="text/css" media="screen, projection" />
<![endif]-->
Also, just a note, you are doing a more general assignment first and another more specfic one second, was this intended? The first css file will be applied to ie7 as well as the second, more specific one.
UPDATE:
Your site css seems to be the following which isn't like you said in your question:
<!--[if lte IE 8]>
<link rel="stylesheet" href="css/iehacks.css" type="text/css" media="screen, projection" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" href="css/iehacks7.css" type="text/css" media="screen, projection" />
<![endif]-->
<!-- [if !IE 7]>
<style type="text/css">
#wrap {display:table;height:100%}
</style>
<![endif]-->

Specific stylesheet for IE8

How can I make a specific CSS stylesheet for Internet Explorer 8?
I mean, how can I load it only if the browser is IE8? (And not IE7 and IE6)
use this
<!--[if IE 8]>
<link href="/stylesheets/iestyle8.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 8]>
<link href="ie8.css" rel="stylesheet" type="text/css" />
<![endif]-->
http://www.quirksmode.org/css/condcom.html
You can use the following:
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="ie8.css" media="screen" />
<![endif]-->

How do I do IE conditionals in CSS?

If I want to add padding based on the browser the user is viewing the page in, is there a way in CSS that I can do something like:
if IE do
padding:5px;
else if not IE do
padding 10px;
Here is a great reference: Quirksmode.org Conditional Comments.
Although the control structure is in the markup and not the CSS, it accomplishes your goal and is usually considered the best practice when serving browser-specific stylesheets.
The best-practice way is to have a single stylesheet for IE-only fixes, like so:
<link rel="stylesheet" href="styles.css" media="screen" type="text/css" />
<!--[if IE]>
<link rel="stylesheet" href="ie-styles.css" media="screen" type="text/css" />
<![endif]-->
Then just override specific problem-causing styles in the ie-styles.css file.
Target ALL VERSIONS of IE
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
Target everything EXCEPT IE
<!--[if !IE]><!-->
<link rel="stylesheet" type="text/css" href="not-ie.css" />
<!--<![endif]-->
Target IE 7 ONLY
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="ie7.css">
<![endif]-->
Target IE 6 ONLY
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="ie6.css" />
<![endif]-->
Target IE 5 ONLY
<!--[if IE 5]>
<link rel="stylesheet" type="text/css" href="ie5.css" />
<![endif]-->
Target IE 5.5 ONLY
<!--[if IE 5.5000]>
<link rel="stylesheet" type="text/css" href="ie55.css" />
<![endif]-->
Target IE 6 and LOWER
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="ie6-and-down.css" />
<![endif]-->
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="ie6-and-down.css" />
<![endif]-->
Target IE 7 and LOWER
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="ie7-and-down.css" />
<![endif]-->
<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="ie7-and-down.css" />
<![endif]-->
Target IE 8 and LOWER
<!--[if lt IE 9]>
<link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->
<!--[if lte IE 8]>
<link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->
Target IE 6 and HIGHER
<!--[if gt IE 5.5]>
<link rel="stylesheet" type="text/css" href="ie6-and-up.css" />
<![endif]-->
<!--[if gte IE 6]>
<link rel="stylesheet" type="text/css" href="ie6-and-up.css" />
<![endif]-->
Target IE 7 and HIGHER
<!--[if gt IE 6]>
<link rel="stylesheet" type="text/css" href="ie7-and-up.css" />
<![endif]-->
<!--[if gte IE 7]>
<link rel="stylesheet" type="text/css" href="ie7-and-up.css" />
<![endif]-->
Target IE 8 and HIGHER
<!--[if gt IE 7]>
<link rel="stylesheet" type="text/css" href="ie8-and-up.css" />
<![endif]-->
<!--[if gte IE 8]>
<link rel="stylesheet" type="text/css" href="ie8-and-up.css" />
<![endif]-->
For complete reference on the topic, Chris Coyier: How To Create an IE-Only Stylesheet
Although the IE conditional can be used only in html and not in the CSS, you can use the following in your CSS files for your quick-and-short tests/hacks.
p {
/* all browsers */
background-color: red;
/* for IE7 and below - append a * before the property */
*background-color: blue;
/* for IE6 and below - append a _ before the property */
_background-color: green;
}
While you can use this for your quick and short requirements, I think, you should follow the suggestion by Mark Hurd given above for production-level heavy codes.
Here's a cleaner way to target IE 10+ in CSS only
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ CSS styles go here */
}
(Source: Phil Newcomer)
If you don't mind ugliness in your code, you can use something like the Holly hack:
div { padding:5px; }
* html div { padding:10px; }
There's a neat CSS Zen Garden example that does this to present two distinct designs, but I don't recall its name.

Resources