W3C home > Mailing lists > Public > www-validator@w3.org > August 2005

Re: not walid?

From: Lachlan Hunt <lachlan.hunt@lachy.id.au>
Date: Sat, 20 Aug 2005 18:58:39 +1000
Message-ID: <4306F0BF.6070502@lachy.id.au>
To: Martin Vičánek <M.Vicanek@seznam.cz>
CC: www-validator@w3.org

Martin Vičánek wrote:
> Why is not this code valid?
> 
> <SCRIPT type="text/javascript">
> 
> 	if (navigator.appName != 'Microsoft Internet Explorer')
> 	document.write ("<style>#menu LI.main A {display : block}</style>");
> 
> </SCRIPT>
> 
> Error Line 134 column 65: end tag for element "STYLE" which is not open.

This explains why it's invalid.
http://www.htmlhelp.com/tools/validator/problems.html#script

A better solution for your needs is to use a CSS hack or a conditional 
comment.  However, the best solution would be to find some CSS that 
works the same for all browsers, and only resort to the use of a hack if 
abolutely necessary.

This will apply only to Internet Explorer.  However, it will apply to 
both IE5/Mac and IE/Win.
* html #menu LI.main A {display : block}

If you only need it to apply to IE/Win, then add this comment hack 
around it.
/* Hide from IE5/Mac \*/
* html #menu LI.main A {display : block}
/* End Hiding */


-- 
Lachlan Hunt
http://lachy.id.au/
Received on Saturday, 20 August 2005 08:58:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:19 GMT