W3C home > Mailing lists > Public > html-tidy@w3.org > July to September 2002

RE: bug report: possible erroneous warnings from tidy in script content

From: Jelks Cabaniss <jelks@jelks.nu>
Date: Thu, 11 Jul 2002 12:00:34 -0400
To: <html-tidy@w3.org>
Message-ID: <001101c228f4$17eaa4a0$6601a8c0@blackie>

Charles Reitzel wrote:

> > document.write("<A href='"..."'>", linktext, "</A>");
> > line 22 column 72 - Warning: '<' + '/' + letter not allowed here

> It wants to be "<\A>", not "</A>".  

I think what Charlie meant to say is "It wants to be "<\/A>".

This issue is probably FAQ question #1 for all Tidy users and [x]HTML
validator users.  The problem is that something that "works" in a
forgiving browser is more often than not valid from a *markup* point of
view.

Bottom line: when coding end tags in Javascript in document.write()'s
and the like, escape them so the XML (for XHTML) or SGML (for HTML)
parser doesn't see it as a "real" (and out-of-place) end tag.  You can
do it in several ways:

	document.write("whatever<\/a>")
	document.write("whatever<" + "/a>")

Etc.  The first one uses a backslash to mean "escape the next
character", i.e. "write it literally".  So the *Javascript* parser will
essentially treat the '\/' the same as a plain '/', and thus "<\/a>" the
same as "</a>", But the *ML parser will see it as a character string of
"<\/a>" and not as an end tag. 

Check out ...

	http://www.htmlhelp.com/tools/validator/problems.html


/Jelks
Received on Thursday, 11 July 2002 12:00:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 April 2012 06:13:52 GMT