Jump to content

Validator errors that aren't really errors


End User

Recommended Posts

I'm getting validator errors from w3.org that aren't really errors, like this one:Line 10, Column 102: end tag for element "B" which is not open…clock').innerHTML="Turns will be added in: <b>"+secs_left+"</b> seconds";}else{Now, clearly, the tag IS closed, but I'm guessing that the w3.org validator is stumbling on the quotes between the tags. Also, it's actually parsing a snippet of javascript, so I'd wonder if anything it reports in there would have any merit.Here's another one....Line 132, Column 57: NET-enabling start-tag requires SHORTTAG YES…ef='info.php?pid=1001'>John Smith</a><br /> <a href='info.php?pid=1000'>Mary…In this case it's calling out the "<br />" tag for using the closing slash. I must be behind the times, I thought that was valid for this doctype:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Link to comment
Share on other sites

In Javascript you should use entities such as < or > and & in order to prevent confusion by parsers, the other option is to include a JS file instead of embedding the code in the document, that way you don't need to make changes to your code.

Link to comment
Share on other sites

is your javascript code within tags similar to comment tags so the validator ignores it instead of treating as part of html code.<script type="text/javascript"><!--//javascript code…clock').innerHTML="Turns will be added in: <b>"+secs_left+"</b> seconds";}else{ //--></script>

Link to comment
Share on other sites

it's well known on these forums that dsonesuk is the master of commenting out Javascript.... :)

Link to comment
Share on other sites

Comments are superfluous in all modern browsers - a CDATA declaration are all that is needed for the validator... and is more "correct" than using comments.

Link to comment
Share on other sites

@enduser I do not know much but I have been working on removing errors every day for the last two weeks. I found that the validator will publish the most important error first. You need to fix errors in order. If you fix one error, many others disappear because they were never really errors but the first error caused the validator to see the following code with errors. I think that is what you are seeing. The validator will even post an error on line 450 before an error on line 200 if it recognizes the error on 450 as more important. I had an extra closing div tag that my developer used to adjust an image into the right place (imagine my surprise!) This div tag created many additional errors above it but it was listed first in the error list. Now my page looks wrong :) but it validates :) .And make sure you follow these rules at w3schools for all your tags. They tell you what must be included and what is depreciated and for which Doc type definition (S=Strict, T=Transitional, and F=Frameset).http://www.w3schools.com/tags/tag_font_style.asp

Link to comment
Share on other sites

Comments are superfluous in all modern browsers - a CDATA declaration are all that is needed for the validator... and is more "correct" than using comments.
I'm not entirely sure, but I seem to remember that the CDATA sections are only available in XHTML and not in HTML.
Link to comment
Share on other sites

Hmm, I'm not sure about that either - both SGML and XML have markup declarations as part of their language, but I don't know whether CDATA is part of the SGML spec or not. It seems to be, but I can't find anything definitive.... there's an easy way to test, though!

Link to comment
Share on other sites

I do not know much but I have been working on removing errors every day for the last two weeks. I found that the validator will publish the most important error first. You need to fix errors in order. If you fix one error, many others disappear because they were never really errors but the first error caused the validator to see the following code with errors. I think that is what you are seeing. The validator will even post an error on line 450 before an error on line 200 if it recognizes the error on 450 as more important.
Yep, errors will "cascade" down the page and there may appear to be many more than there really are. On the new site/app I just completed I got about 15 warnings and 3 errors...the "errors" were the "<b>" tags not being parsed because they were part of a javascript statement and some "<br />" tags being present. The warnings were all due to missing "alt" tags. So there wasn't really anything drastically wrong. Added the "alt" tags and it's fine. I'm not obsessive about making sure that the HTML validates 100%...it's nice if it does, but there are times when it's unimportant to me or just doesn't matter.
Link to comment
Share on other sites

Hmm, I'm not sure about that either - both SGML and XML have markup declarations as part of their language, but I don't know whether CDATA is part of the SGML spec or not. It seems to be, but I can't find anything definitive.... there's an easy way to test, though!
so what's a practical convention for commenting out javascript? (HTML or XHTML)
Link to comment
Share on other sites

I'll fold after

<script type="text/javascript">/*<![CDATA[*//*---->*//*--*//*]]>*/</script>
with
SGML also defines the use of marked sections for CDATA content, within which "<" is not treated as the start of a tag, e.g.,<![CDATA[ <an> example of <sgml> markup that is not <painful> to write with < and such.]]>
From: http://www.w3.org/TR/1999/REC-html401-1999...specifying-data :)
Link to comment
Share on other sites

So the answer is yes, the CDATA markup declaration is present in both SGML and XML, and can be used.

Link to comment
Share on other sites

I don't know about you, but I prefer to "escape" JavaScript by simply placing all of it in a separate file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...