Forum Moderators: open
<script type="text/javascript">
<!--
#page_wrapper, #content {
width: expression(document.body.clientWidth < 602? "600px" : document.body.clientWidth > 802? "800px: : "auto");
//-->}
</script>
i can get IE to recognize it if i put it in my css, but of course then my css doesn't validate. i put it in the <head> of my page, but i must have something wrong because IE isn't recognizing it. should i put it in an external file? do i need to include the <style> tags somewhere? if so where?
But, as you have found, it is not valid CSS - since it uses IE's expression() to use a snippet of JS within the CSS file itself. This will not validate.
You either have to put up with your CSS not validating, or put your IE only CSS in a separate file and include it with a conditional comment - this, I think, is the best solution, if you must this form of JS in your CSS file.
In your <head> section:
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="ieonly.css">
<![endif]-->
This will pull in the "ieonly.css" CSS file only for IE, less than or equal to version 6.
i put the following in a file called ieonly.css, inside the style_sheets folder:
#page_wrapper, #content {
width: expression(document.body.clientWidth < 602? "600px" : document.body.clientWidth > 802? "800px: : "auto");
}
i put this code in the <head>:
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="style_sheets/ieonly.css">
<![endif]-->
should ie be recognizing it when i view the html file from html-kit, or will it only work when it's live? or does this particular css file have to be at the root level for some reason? or do i have something wrong in the expression()?
thanks,
kam