W3C home > Mailing lists > Public > www-validator@w3.org > February 2008

Re: document type does not allow element "style" here

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Thu, 14 Feb 2008 20:57:50 +0200
Message-ID: <015001c86f3b$8201d190$0300000a@DOCENDO>
To: (wrong string) ürgen Schmid" <JueSchmid@t-online.de>, <www-validator@w3.org>

Jürgen Schmid wrote:

> This module puts the following lines into the html:
>
> <script type="text/javascript">$("head").append("<style
> type='text/css'>form.rating{display:none}</style>");
> if ($.browser.safari){ $("head").find("style:last").append(" ")
> }</script>

>From the HTML perspective, that's just some stuff inside a <script> 
element, and all that matters in HTML parsing is the markup-significant 
constructs there.

> The validator tells me:
>
> Line 51, Column 71: document type does not allow element "style" here.

That's right, since such nesting is not allowed and the <script> element 
actually contains a <style> element.

> The developer of the
> module tells me, that the script is ok.

He's wrong, and should know better. Tell him to learn the HTML syntax. 
If needed, the validator FAQ should be consulted. A construct like with 
"<" followed by a letter is treated as starting a tag, hence invalid 
inside a <script> element. There are various ways to deal with this. 
Perhaps the simplest is to use "&lt;" instead of "<".

Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/ 
Received on Thursday, 14 February 2008 18:58:09 GMT

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