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

Re: span elements in script elements

From: David Dorward <david@dorward.me.uk>
Date: Wed, 14 May 2008 15:11:07 +0100
Cc: <www-validator@w3.org>
Message-Id: <5127421B-96EA-4443-8A52-A9F265DD2BD3@dorward.me.uk>
To: <david.fosberry@fosberry.com>

On 14 May 2008, at 10:39, David Fosberry wrote:
> Whilst validating www.fosberry.com/cgi/GuestBook.pl, I received  
> error 64, about a <span> element “not allowed here“.
> I believe this is a bug in the validator.

It isn't.

> The <span> element is included in a literal string in a <script>  
> element, and as such should not be parsed by the HTML validator.

See http://www.w3.org/TR/xhtml1/#h-4.8 while being aware of the  
problems this causes if you serve your XHTML as text/html ( http://www.w3.org/TR/xhtml1/#C_4 
  and http://www.webdevout.net/articles/beware-of-xhtml ).

>  I will of course attempt a work-around, by embedding the JavaScript  
> in HTML comment markers (inside the <script> element), but it really  
> should not be necessary.

User agents treating your code as XHTML will ignore the entire script  
(since it is commented out). XHTML and HTML are different.

David Dorward
Received on Wednesday, 14 May 2008 14:11:57 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:59:08 UTC