Re: Valid positioning of script elements

I agree.  This seems strange to me as well.  Being able to put script tags in a
table tag allows you to create more dynamic pages.  You can create server side
scripts (using ASP for example) that dynamically fills in a table, but it's
invalid to use client side scripting to accomplish the same thing.  I'm not sure
if this is an issue for the html list or the validator list (so I'll send this
to both).

The following code is invalid, according to the w3 validator.  But I would argue
that it should not be.  Can someone offer an explanation as to why it should be

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


     <script language="Javascript" type="text/javascript">
     var str = "<tr><td>2,1<\/td><\/tr>"


Clover Andrew <> on 06/05/2000 02:44:00 PM

To:   "''" <>
cc:    (bcc: Peter Foti)

Subject:  Valid positioning of script elements

I note from the HTML 4.01 DTD and from coming a cropper on the
validator that one may only insert <script>s at block-level,
inline, or in <head>. It is invalid for a script to live in
structural markup such as <table>, <tr>, <dl> and so on.

Is there any particular rationale behind this definition, or is
it simply arbitrary? (It differs from every browser's
implementation of <script>, though of course that on its own
doesn't mean anything.) Is there any chance of a change in the

It would be quite useful to me to be able to, for example,
document.write(some extra table rows), to produce content
that only appears when JavaScript is enabled (with different,
backup behaviour where scripting is not supported, natch).
The alternative is to write <tr> and <td> elements with
block-level <script>s inside them, leaving empty rows
when scripting is unavailable. This does not appeal to
me aesthetically. :-)

Andrew Clover
Technical Support AG

Received on Monday, 5 June 2000 16:51:55 UTC