Re: elements other than HTML on web pages

John Sankey wrote:

> I'd like to suggest that an HTML parser such as you provide should only look
> at what is between the <html> and </html> tags. HTML should not be
> considered invalid if it is followed by a <script>...</script> - that should
> be left for a script parser e.g. Javascript. More and more sites are tacking
> on a segment of Javascript for various reasons (e.g. Geocities) - surely a
> page with 100% valid HTML between the <html> and  </html> tags should pass.

Nope. SCRIPT, indeed most elements, are invalid outside HTML. If your
provider modifies your HTML you should consider switching providers IMO.

A workaround for the specific example you provided is to leave off the
closing tag for HTML. That way the SCRIPT element will be interpreted as
being inside the HTML element and it will be implicitly closed at the
end of the document. Always provided, of course, that you are using a
document type that allows implicitly closed elements.

e.g.
<HTML>
<HEAD><TITLE>Example</TITLE></HEAD>
<BODY><P>Whatever...</P></BODY>
<!-- The end of your code -->
<!-- GeoCities tacks on the following -->
<SCRIPT><!-- some JavaScript --></SCRIPT>
<!-- The HTML element is implicitly closed here -->
</HTML>

Received on Tuesday, 3 October 2000 20:12:27 UTC