Forum Moderators: open
The first is a meta tag inside <noscript> which redirects the user to ask them to turn JavaScript on if they can. If they can't, I direct them to non-JavaScript pages.
Here is the tag:
<noscript><meta http-equiv="refresh" content="0; url=no_script/bridge.htm"></noscript>
And this is the warning:
Error: element "META" not allowed here; check which elements this element may be contained within
The next is the closing </head> tag and this is the warning:
Error: end tag for element "HEAD" which is not open; try removing the end tag or check for improper nesting of elements
The last is the <body> tag. And the warning:
Error: element "BODY" not allowed here; check which elements this element may be contained within
This is the top portion of the page. There are no other head tags in the page and one closing body tag:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Test</title>
<noscript><meta http-equiv="refresh" content="0; url=no_script/bridge.htm"></noscript>
<script type="text/javascript" language="javascript" src="docs/Scripts.js"></script>
</head>
<body>
Thanks for your help.
The problem is that NOSCRIPT isn't allowed in HEAD because it's a block element [w3.org] like P and DIV. (SCRIPT is a special element that's treated differently.) Three lines in the DTD explain this:
%head.misc [w3.org] includes SCRIPT, STYLE, META, LINK, and OBJECT.
%head.content [w3.org] includes TITLE and BASE.
The element defintion for HEAD [w3.org] limits its content to %head.misc and &head.content. Any other elements are illegal in HEAD.
Explaining why you got the three errors you did:
As far as SGML parsers are concerned, you closed the HEAD as soon as you used the forbidden NOSCRIPT. HEAD and BODY tags are optional in the DTD you used, so the parser has to assume you've started the BODY when it sees an element that only occurs in the BODY. With me so far?
So your first error is telling you that you've got a META in the NOSCRIPT, which means you've META in the BODY. That is Not Allowed. You're lucky: In the Good Old Days, some validators might have given you two error messages there.
The second error is telling you that you've got an illegal </HEAD> tag, because you've technically stuck it in the middle of the implied BODY element.
Likewise, the third error is telling you that the explicit BODY element is illegal, because your document already has an implied BODY. (A valid HTML document can only have one BODY element.)
SGML -- It's black magic, but it's the black magic the Web is built on.
One of the things I like about it is that the software not only warns you that your code is funky, it offers suggestions for de-funkifying it.
It's the Dr. Scholls of HTML.
There's a free download at Bradleysoft.com (I think that's how you spell it). They're the same folks who made TopStyle.
Is there a better/correct way of redirecting the JavaScript disabled? Should I just put a link to the <noscript> pages within the tag and in the body?
martinibuster, I haven't tried a CSE HTML Validator yet but will. There is no such thing as smelling to fresh :)
<script type="text/javascript">
self.location.replace('js_version.html');
</script>
Using replace() means that the new page will replace the current page in the browser's History list -- if you used self.location='js_version.html' you would break the Back button for all JavaScript enabled browsers.
I've never liked the fact that I was killing the back button on disabled browsers. Is there a cleaner method of directing disabled browsers to the right pages?
Your wisdom is appreciated.