PDA

View Full Version : <noscript> and w3c



marain
02-13-2013, 08:55 PM
The w3c validator gives an error message when I try to validate http://www.njdriverslicenses.com/. The relevant code is...


&nbsp;&nbsp;<!-- Site Meter -->
<script type="text/javascript" src="http://s50.sitemeter.com/js/counter.js?site=s50NJDrivers">
</script>
<noscript>
<a href="http://s50.sitemeter.com/stats.asp?site=s50NJDrivers" target="_top">
<img src="http://s50.sitemeter.com/meter.asp?site=s50NJDrivers" alt="Site Meter" border="0"/></a>
</noscript>
<!-- Copyright (c)2009 Site Meter -->

It strikes me as pretty weird that <noscript> would flag where <script> is allowed. Can anyone see whether I am missing something?

A.

djr33
02-13-2013, 09:28 PM
I think it might be because you're including that within a paragraph. I'm not sure why <script> is allowed, though.

traq
02-13-2013, 10:16 PM
You're using an xhtml doctype.

The noscript element must not be used in XML documents.

You might want to reconsider using an xhtml doctype.
The xhtml specification is no longer under active development; it is effectively dead.
It is allowed to use xhtml syntax with HTML5, but there's really no point in doing so.
.
You won't run into obscure errors (like this one) anymore. There are many, many things in common practice that don't "jive" with xhtml. You're hard-pressed to find an xhtml document on the web that actually validates as xml.
.
[true] xml does not allow graceful error handling: if a browser were to correctly parse this -
<!-- everything else is completely correct,
but this img tag is not properly closed-->
<img src="mypic.jpg">then it would fail, come to a complete stop in the middle of whatever it was doing, and refuse to do anything further. With the advent of HTML5, there are specific rules for handling mistakes in markup, so browsers will handle it in a graceful, predictable manner (even if it's not exactly what you wanted to happen).
.
Your page (like almost all xhtml pages in existence) is not being served with the proper http headers (it's served as "text/html"), so no browser considers it xhtml anyway: it's being treated as "broken" html. Older versions of IE don't support xhtml at all, even with the proper http headers.
(This is my #1 reason for abandoning xhtml: in practice, it has always been completely useless, and even a bit of a usability risk.)

The current recommended doctype is <!doctype html>. This will trigger standards mode in all major browsers, and is completely backwards-compatible (back to the very first day any browser cared at all about doctypes).

marain
02-13-2013, 11:28 PM
Traq, your surmise was correct: Taking the </noscript> outside the paragraph tags solved the problem.

Now as to your other suggestion, were I to change the doctype as you suggest, can you give me a feel for what other changes would be required as a result? For example, would self closing tags, e.g. <br /> still work (and be accepted by w3c)?

Thanks again.

A.

traq
02-14-2013, 01:09 AM
Traq, your surmise was correct: Taking the </noscript> outside the paragraph tags solved the problem.actually, Daniel said that. :)


Now as to your other suggestion, were I to change the doctype as you suggest, can you give me a feel for what other changes would be required as a result? For example, would self closing tags, e.g. <br /> still work (and be accepted by w3c)?

It's perfectly acceptable to use an XML serialization (i.e., XHTML-style syntax) with HTML5.

You can override the doctype in the validator (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.njdriverslicenses.com%2F&charset=%28detect+automatically%29&doctype=HTML5&group=0&user-agent=W3C_Validator%2F1.3) to see what changes you might need to make if you switched. Mostly minor stuff, in the case of your home page. Unregistered meta names, obsolete attribute values, presentational ("should-be-in-CSS") attributes. Nothing that would actually cause problems.

marain
02-14-2013, 10:37 AM
Dan, Traq, jscheuer1, beverleyh, it's difficult to keep things straight when I'm surrounded by geniuses ;-)

Thanks all.

A.
Official Junior Coder

traq
02-14-2013, 03:17 PM
You're quite welcome. Just to clarify, my suggestion about changing the doctype was just that. If you're not sure about it, don't worry; it's not critical.