- From: Bjoern Hoehrmann <derhoermi@gmx.net>
- Date: Thu, 08 Jul 2004 03:45:33 +0200
- To: ".: Stefano Bisetto :." <stefano.bis@libero.it>
- Cc: <www-validator@w3.org>
* .: Stefano Bisetto :. wrote: >The "a" tag is correctly open. It's contained in a javascript >so the validator doesn't recognize it. The <script> and <style> elements in HTML 4 are very special elements. Here is an example: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> <script type="text/javascript"> alert("Björn"); </script> </head> <body> <p>...</p> </body> </html> If you load the document in a browser that supports scripting, it would show you a message box containing "Björn" rather than "Björn". This is because the browser ignores markup inside the <script> element. Here is another example: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> <script type="text/javascript"> alert("Comments are <!--NOT--> ignored!"); </script> </head> <body> <p>...</p> </body> </html> You will get a message box containing "Comments are <!--NOT--> ignored!" for the same reason, markup is ignored. But the browser somehow needs to know where the <script> element is finished. It was unfortunately not possible to specify that everything up to </script> is considered part of the script, instead the first occurence of </ followed by a letter A-Za-z determines the end of the element. Here is an (illegal!) example: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> </head> <body> <script type="text/javascript"> document.write("<p>...</p>"); </script> </body> </html> In this case, the first occurence of </ followed by a letter would be </p>! If you ignore the document.write() and ignore the <p> (remember, markup is ignored inside the <script> element) you get something like <script type="text/javascript">...</p>"); </script> And </p> does not match </script>, the validator complains end tag for element "P" which is not open It isn't, is it? Remember that comments are ignored too, but let's have a look at them again <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> </head> <body> <script type="text/javascript"><!-- alert("--> BUH!"); //--></script> </body> </html> The browser would present you a message box containing "--> BUH!". If it had ignored comments you would not see the "BUH!", would you? But let's do another (illegal!) example <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> </head> <body> <script type="text/javascript"><!-- document.write("<p>...</p>"); //--></script> </body> </html> So the <!-- gets ignored and the <p> gets ignored... then we've got again <script type="text/javascript">...</p>"); //--></script> And </p> does not match </script>. As before. The following resources might also be helpful in this regard: * http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2 * http://www.htmlhelp.com/tools/validator/problems.html#script
Received on Wednesday, 7 July 2004 21:46:14 UTC