Re: Valid positioning of script elements

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