W3C validator doesn't like this line

N

NickC

Can anyone spot why the W3C validator dosen't like this line:

function onLine() {document.getElementById("SiteStatus").innerHTML = "<A
HREF='http://AssocData.co.uk/StatusImg.gif'>Online</A>.";}

It returns the error:

1.. Line 21, column 126: end tag for element "A" which is not open
(explain...).
...ocData.co.uk/StatusImg.gif'>Online</A>.";}
^
but I cannot see why or how to stop it, any ideas?

Thanks,
Nick
 
N

NickC

Wow thanks Jan that worked... but I don't understand why.

Help much appreciated.

Nick
 
C

cwdjr

Re: Why the backslash is required. Below is what the W3C has to say on
this subject. You can reach this and more from their validator site.
Not everyone always agrees with the W3C, but at least you have their
statement given below.____________________________________________Writing
HTML in a SCRIPT ElementA common error (and the most common source of
erroneous bug reports for the WDG HTML Validator) occurs when writing
HTML tags within a SCRIPT element:<script type="text/javascript"> <!--
// This is an error! document.write("</P>"); // -->
</script>Technically, the first occurrence of "</" followed by any
letter is considered the end tag for the SCRIPT element. While
browsers are forgiving in this, authors should avoid using strings
such as "</P>" in their embedded scripts. JavaScript allows authors to
use a backslash to avoid ending the SCRIPT element prematurely:<script
type="text/javascript"> <!-- document.write("<\/P>"); // -->
</script>________________________________________________I copied and
pasted the above from the W3C site. Sometimes posting from Google
messes up the code. If so, go to the W3C validator site to find a
better copy. I use the Yahoo address to avoid spam being sent to my
ISP e-mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top