W3C home > Mailing lists > Public > www-validator@w3.org > June 2000

Re: Valid positioning of script elements

From: Bertilo Wennergren <bertilow@hem.passagen.se>
Date: Tue, 6 Jun 2000 00:22:36 +0200
Message-ID: <00bf01bfcf3c$a0c1b520$fbe05dd5@chello.se>
To: <pdf@bizfon.com>
Cc: <www-validator@w3.org>
Peter Foti:

> I realize that the method you show below is valid.  But what I want to know is
> why is the other method invalid?  It's much easier to write:
 
> <table>
>      <tr>
> 
> than it is to write:
> 
> <script type="text/javascript">
>    document.write('<table>');
>    document.write('<tr>');
> ...

The reason is the rules in the DTD. Script is not an inline element.
Now, why that rule is as it is, is another question that I can't
answer.

Your problem is comparably small. Image trying to document.write
two different body-start tags (with different attributes depending
on e.g. on the client identity). For correct nesting of tags you
have to document.write the whole darn document from <body> to
</body> inclusive. A pain in most body parts if it's just a few
attributes that really need to vary. But them's the rules!

#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                     <bertilow@hem.passagen.se>
#####################################################################
Received on Monday, 5 June 2000 18:18:55 UTC

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