/    Sign up×
Community /Pin to ProfileBookmark

Need fresh eyes to find parse error

This code generates a couple errors on the w3.org validator, and I just can’t see what’s wrong. Maybe someone who hasn’t been staring at it for the last hour can see the obvious for me?

[code=html]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
<html lang=’en’>
<head>
<META HTTP-EQUIV=’Content-Type’ CONTENT=’text/html; charset=ISO-8859-1′>
<title>Page title</title>
<style type=”text/css”>
<!–
body {
margin: 0;
padding: 0px;
background-color: #919fa8;
font: 90% verdana, helvetica, sans-serif;
}
.container {
margin: 10px auto;
width: 750px;
background-color: white;
padding: 10px;
color: #123;
}
h1 {
font-size: x-large;
letter-spacing: 0.08em;
color: #369;
margin: 5px 0 0 0;
padding: 0;
}
h2 {
font-size: medium;
color: #369;
margin: 0 0 10px 0;
padding: 0 0 10px 0;
border-bottom: solid 2px #919fa8;
}
h3, h4 {
color: #369;
margin: 1.5em 0 0 0;
}
a {color: #369;}
a:visited {color: #666;}
a:hover {color: #c33;}
iframe {
width: 724px;
height: 600px;
}
#valid {text-align: center;}
–>
</style>
</head>
<body>
<p>test</p>
</body>
</html>
[/code]

The error messages:

[quote]

# Error Line 50 column 5: document type does not allow element “BODY” here.

<body>

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements — such as a “style” element in the “body” section instead of inside “head” — or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML’s rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML’s “self-closing” tags for “meta” and “link” in the “head” section of a HTML document may cause the parser to infer the end of the “head” section and the beginning of the “body” section (where “link” and “meta” are not allowed; hence the reported error).

&#9993;

# Error Line 53 column 6: end tag for “HTML” which is not finished.

</html>

Most likely, You nested tags and closed them in the wrong order. For example <p><em>…</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>…</em></p>

Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is “not finished”, not complete. For instance, <head> generally requires a <title>, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.

[/quote]

to post a comment
HTML

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogauthorSep 02.2005 — OK, I've narrowed it down to the doctype. If I replace the frames doctype with this strict one, I get no errors:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Copy linkTweet thisAlerts:
@NogDogauthorSep 02.2005 — I got off my lazy butt and got rid of the iframe I was going to use for convenience's sake, so I went back to my usual 4.01 Strict doctype, therefore it's not a problem at the moment. But should anyone know what the problem was, I'd still be interested in knowing.
Copy linkTweet thisAlerts:
@ray326Sep 03.2005 — A frameset can't have a body?
Copy linkTweet thisAlerts:
@NogDogauthorSep 03.2005 — A frameset can't have a body?[/QUOTE]
Doh! Strict complained because I had an IFRAME, so I thought I needed to use a "frame" doctype. I didn't see that it said "frameset". So you use the "transitional" doctype if you want to use an iframe?
Copy linkTweet thisAlerts:
@ray326Sep 03.2005 — I guess so. That was just a WAG (hence the "?") from what I had read in another message a few minutes before seeing yours.

Ah, check out the iframe entry in [URL=http://www.w3.org/TR/html401/index/elements.html]this table[/URL]. It indicates iframe is only in the Loose DTD.
Copy linkTweet thisAlerts:
@CharlesSep 03.2005 — So you use the "transitional" doctype if you want to use an iframe?[/QUOTE]Yes. And if you want to be strict about it then you should use the OBJECT element for your inline frame.
Copy linkTweet thisAlerts:
@NogDogauthorSep 03.2005 — Yes. And if you want to be strict about it then you should use the OBJECT element for your inline frame.[/QUOTE]
Yeah, I noticed references to that last night while looking into this. It's on my list of things to look into further now. ?
×

Success!

Help @NogDog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...