HTML Validation Form [Was: Nesting of HTML elements ]

Daniel W. Connolly (connolly@hal.com)
Tue, 11 Oct 1994 23:01:03 +0100

In message <199410110938.CAA02365@netcom15.netcom.com>, Robert C Powell writes:
>
>Hello. Can anyone point me to a definitive answer as to whether
>or not HTML tags - for headers and text elements - can be nested
>and have the appearence be relatively consistent
>(not completely dependant on the specific HTML parser used)
>vs. non-nested tags.

I like that: "a difinitive answer" -- not THE definitive answer, but
any old definitive answer. How about this one: no.

But seriously... the HTML working group has been debating questions
like this since around May. We even fire up the browsers and test them
when in doubt.

The result of all the hot air is the HTML 2.0 specification, coming
soon to an RFC archive near you. You can join in the fun by visiting:

"HTML Specification Review Materials"
http://www.hal.com/%7Econnolly/html-spec

>The HTML DTD does mention
>
><!ENTITY % stext -- as htext but also nested structure --
> "P | HR | %list | DL | ADDRESS
> | PRE | BLOCKQUOTE
> | %literal | %htext">
>
>but I have to admit to ignorance in reading BNF grammer,
>such as in the DTD, correctly.

Well, we realized that for a few folks out there, the DTD doesn't make
things crystal clear. So Mark Gaither and I at HaL have set up a forms
interface to a validating SGML parser at

"HaLsoft HTML Validation Service"
http://www.hal.com/%7Econnolly/html-test/service/validation-form.html

so you can ask questions just like the one below:

>In english, is browser performance well defined for cases like:
>
><BODY>
><H1> heading1 <P>
><H2> heading 2 <P>
><H3> heading 3 <P>
></H3>
></H2>
></H1>
></BODY>

The validation service responds:
Errors

sgmls: SGML error at -, line 8 at ">":
H1 end-tag implied by P start-tag; not minimizable
sgmls: SGML error at -, line 9 at ">":
H2 end-tag implied by P start-tag; not minimizable
sgmls: SGML error at -, line 10 at ">":
H3 end-tag implied by P start-tag; not minimizable
sgmls: SGML error at -, line 11 at ">":
H3 end-tag ignored: doesn't end any open element (current is P)
sgmls: SGML error at -, line 12 at ">":
H2 end-tag ignored: doesn't end any open element (current is P)
sgmls: SGML error at -, line 13 at ">":
H1 end-tag ignored: doesn't end any open element (current is P)
sgmls: SGML error at -, line 16 at ">":
BODY end-tag ignored: doesn't end any open element (current is HTML)

So first we notice that P is not allowed inside H1. (Sorry if the
error messages are hard to understand. We didn't write that part
of the software, and if we figure out a good way to do it, we'll
make the messages easier to read.)

So if we get rid of the P's:

Errors

sgmls: SGML error at -, line 9 at ">":
H1 end-tag implied by H2 start-tag; not minimizable
sgmls: SGML error at -, line 10 at ">":
H2 end-tag implied by H3 start-tag; not minimizable
sgmls: SGML error at -, line 12 at ">":
H2 end-tag ignored: doesn't end any open element (current is BODY)
sgmls: SGML error at -, line 13 at ">":
H1 end-tag ignored: doesn't end any open element (current is BODY)
sgmls: SGML error at -, line 16 at ">":
BODY end-tag ignored: doesn't end any open element (current is HTML)

So we see that you can't nest headings this way.

>vs. (will this appear the same as)
>
><BODY>
><H1> heading1 <P> </H1>
><H2> heading 2 <P> </H2>
><H3> heading 3 <P> </H3>
></BODY>

If we change this to:

<BODY>
<H1> heading1 </H1>
<p>
<H2> heading 2 </H2>
<p>
<H3> heading 3 </H3>
<p>
</BODY>

Then the results are much happier:

Parsed Output (Element Structure Information Set)

(HTML
(HEAD
(TITLE
)TITLE
)HEAD
(BODY
(H1
- heading1
)H1
-\n
(P
)P
(H2
- heading 2
)H2
-\n
(P
)P
(H3
- heading 3
)H3
-\n
(P
)P
)BODY
)HTML
C

I hope this helps!

Dan