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

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 UTC