PDA

View Full Version : why IE doesn't load this css ?


aneuryzma
06-08-2009, 04:53 AM
Hi,
I don't understand why IE is not loading its own css. This is the code:

<head>

<link href="standardStyle.css" rel="stylesheet" type="text/css" media=screen>

<!--[if IE 6]>
<link href="ie_style.css" rel="stylesheet" type="text/css" media=screen>
<![endif]-->

</head>

ie_style.css is not loaded :(
I've IE 7.0

thanks

soakdigital
06-08-2009, 04:57 AM
You need to use <!--[if lte IE 7]> if you want to target IEs less than or equal to version 7

aneuryzma
06-08-2009, 05:00 AM
hi, thanks for reply. I've changed to

<!--[if lte IE 7]>
<link href="ie_style.css" rel="stylesheet" type="text/css" media=screen>
<![endif]-->


but still not working...
I'm sure the css path is correct because I've tried to load it normally and it works.

soakdigital
06-08-2009, 05:08 AM
I'd try downloading IETester (http://www.my-debugbar.com/wiki/IETester/HomePage) to double check or try 'lte IE 8' to be certain.

aneuryzma
06-08-2009, 05:18 AM
thanks for the tip.

I've loaded it with all the IE in IETester and the css file is still ignored...

I really don't understand why:

- if I normally load the css, it works
- the IE css lines in my html document are located at the end of the <head> tag, so it can't be overwritten by the standard css file...

thanks

soakdigital
06-08-2009, 05:52 AM
That is odd, could you post your html?

A quick example of conditional usage:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" media="screen" href="/media/css/styles.css?" />
<!--[if lte IE 8]><link type="text/css" rel="stylesheet" href="/media/css/styles-ie8.css" /><![endif]-->
<!--[if lte IE 6]><link type="text/css" rel="stylesheet" href="/media/css/styles-ie6.css" /><![endif]-->
<title>Test</title>
</head>

nuclearvapid
06-08-2009, 06:13 AM
hacks are buggy and dont always work and that's just the way it is.
best to use a javascript sniffer and direct it to the file that way.

<script language="JavaScript">
<!--
ie6 = ((navigator.appName == "Microsoft Internet Explorer")&&(parseInt(navigator.appVersion) >= 6 ))
ie7 = ((navigator.appName == "Microsoft Internet Explorer")&&(parseInt(navigator.appVersion) < 7 ))


if(ie6) { document.writeln("<LINK title=css href='/css/style_ie6.css' rel=stylesheet>");}
else if(ie7) { document.writeln("<LINK title=css href='/css/style_ie7.css' rel=stylesheet>");}
else { document.writeln("<LINK title=css href='/css/style.css' rel=stylesheet>");} //mozillia
//-->
</script>

soakdigital
06-08-2009, 06:30 AM
best to use a javascript sniffer and direct it to the file that way.


I'd strongly disagree with this, the point of using conditional stylesheets is to avoid CSS hacks, which are buggy and unreliable. JS browser sniffing has never been good practice, though for me it's a non-starter since it relies on a JS-enabled browser.

¥åßßå
06-08-2009, 09:12 AM
I'd strongly disagree with this, [...] JS browser sniffing has never been good practice, though for me it's a non-starter since it relies on a JS-enabled browser.

I agree with him disagreeing, and for all the same reasons ++ any script that has a language attribute is older than my grandma and is best avoided ;)

¥