Understanding simplest HTML page - Page 5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: Understanding simplest HTML page

On Thu, 24 Nov 2005, Toby Inkster wrote:

Quoted text here. Click to load it

We had one of those, once - like this:

Oh, not *that* kind of PS2  ;-}

Re: Understanding simplest HTML page

On Thu, 17 Nov 2005 09:08:22 +1000, Eric Lindsay

Quoted text here. Click to load it

These tags are required, but they're required by external good-practice
coding standards, not by the specification itself.

A correct HTML parser is based around SGML practice and the HTML DTD
(either referenced by the doctype or assumed). This parser "knows" that
a HTML document must have a <html> element at the root, <head> and
<body> children within that, and a number of tags that can only appear
within the <body>   (and much else besides).

Note also that your terminology of "tag pairs" is useful,  because pairs
of tags in a document are only "tag pairs" - they're not an "element"
until _after_ they've been parsed.  An element is still produced by the
parser whether the tags are paired and valid or not (if the parser
doesn't give up altogether).

A HTML document containing a <p> start tag alone _MUST_ place this
within the <html> and <body> elements, because that's the only place
it's allowed to be   -- even if you never use a <html> or <body> tag.

There are a few problems with this.

 - it's not human friendly.

 - it relies on correct parser behaviour

 - if the document is invalid HTML, then it's hard to recover when so
much is based on inference.  Is the sequence <p><link> a <head> with a
spurious <p> in it, or is it a <body> with a spurious <link> in it ?

So missing out <body> just isn't a good thing to do. Missing out </p> is
much less critical.

 Cats have nine lives, which is why they rarely post to Usenet.

Re: Understanding simplest HTML page

Andy Dingley wrote:
Quoted text here. Click to load it

That's a matter of opinion, some people prefer not having unnecessary
tags in the source.

Quoted text here. Click to load it

Indeed, and that's the best practical reason to always include them.  I
know at least IE has serious problems with this:

<!DOCTYPE html ... >
<form ... >

IE will put the form element within the head and the p element within
the body.  Using at least the body start-tag does fix that erroneous

Quoted text here. Click to load it

The head element wouldn't be implied, unless it was a valid child of the
p element, which it is not.  As for the link implying the end of the p
element, I'm not sure of the exact SGML rules in this case, but the
validator shows (in the parse tree) that it remains a child of the p

Lachlan Hunt
http://lachy.id.au /
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox

Site Timeline