W3C home > Mailing lists > Public > html-tidy@w3.org > October to December 1999

HTML-Tidy and JavaScript issues

From: Michael Sorens <wong.sorens@mindspring.com>
Date: Thu, 23 Dec 1999 11:16:50 -0800
Message-ID: <006901bf4d7a$485bfc40$cda9cdcf@worldnet.att.net>
To: <html-tidy@w3.org>
I just discovered HTML-Tidy--what a tremendous tool! Particularly for the capability to upgrade to style sheets which is originally why I looked at it. Thank you for creating this!

Below are the warnings generated by HTML-Tidy for a rather small HTML file. I suspect most of these are valid warnings due to my lack of knowledge, particularly since I ran the file through the WDG validator which reported the same issues.

Valid HTML inside a writeln() reported as an error
Items 1 and 2 are complaining about a piece of valid HTML inside a JavaScript function:
"", "1","index.html","11","46","'<' + '/' + letter not allowed here"
"", "2","index.html","11","51","'<' + '/' + letter not allowed here"
Here's the code fragment it refers to, i.e. the </TD> and </TR> inside the writeln():
<script type="text/javascript">
function mainSection () {
document.writeln('<TR><TD COLSPAN=3 BGCOLOR="#000000" HEIGHT=10>' +
'<IMG SRC="graphics/onepixel.gif"></TD></TR>'); 

Item reported missing, but buried in JavaScript
Item 3 is wrong, in that the 'title' element is generated inside the support.js file.
Of course, HTML-Tidy has no way of knowing that, which leads me to believe that there are certain things that must be in-line code, not buried within JavaScript, e.g. <TITLE>, <LINK>, and others. If I am correct, where would this be documented?
"", "3","index.html","39","1","inserting missing 'title' element"
Here's my code fragment, inside the <HEAD>...</HEAD>:
<script type="text/javascript">
  setTitle("Michael Sorens' Portfolio");

Possible improper placement of <script> tag
The next 9 warnings are all the same issue: I am using a JavaScript "subroutine" inside a table;
I gather that this is not a valid thing to do, but I looked all over the W3C site and could not find it documented:
"", "4","index.html","48","1","missing <tr>"
"", "5","index.html","48","1","<script> isn't allowed in <tr> elements"
"", "6","index.html","49","1","missing <td>"
"", "9","index.html","138","1","missing <tr>"
"", "10","index.html","138","1","<script> isn't allowed in <tr> elements"
"", "11","index.html","139","1","missing <td>"
"", "13","index.html","176","1","missing <tr>"
"", "14","index.html","176","1","<script> isn't allowed in <tr> elements"
"", "15","index.html","177","1","missing <td>"

Here's the code fragment:
<table border=0 cellpadding=2 summary="ecent Work">
<script type="text/javascript">mainSection();</script>

The mainSection() function outputs a complete "<TR>...</TR>" line, as shown earlier in this note.

Possible invalid expression
This last set involves the notation "&{JavaScript-expr};" as an attribute value, which should be valid.
"", "7","index.html","61","18","unescaped & which should be written as &amp;"
"", "8","index.html","75","18","unescaped & which should be written as &amp;"
"", "12","index.html","148","18","unescaped & which should be written as &amp;"
<td><FONT SIZE=&{fontSize};>

where "fontSize" is a valid JavaScript variable I've defined. The expression works in Netscape 4 but it does not work in Internet Explorer 4 or 5.

Missed catching one error
The WDG HTML validator found one more which HTML-Tidy did not!

Line 41, character 15: <body BGCOLOR=#FFFFFF>
Error: an attribute value must be quoted if it contains any character other than letters (A-Za-z), digits, hyphens, and periods; use quotes if in doubt

But to give HTML-Tidy its due worth, the WDG validator reported poorly in a couple of instances. Example: where HTML-Tidy indicated "missing 'title' element", the WDG validator reported just: 
Error: missing a required sub-element of HEAD

--Michael Sorens
Received on Thursday, 23 December 1999 14:13:27 UTC

This archive was generated by hypermail 2.3.1 : Friday, 13 July 2018 08:58:58 UTC