RE: It isn't a standard if it has hidden rules for historical reasons.

Aaron Oxford wrote:

> Hi Phil and thanks for the reply,

You're welcome, Aaron.

> I had to read it three times but I think I know what is going on and
> hopefully you can confirm this for me.

> First of all, are you telling my mental model isn't the way the world
> works? I hate when that happens! :-)

'Fraid so : it happens to all of us :-)

> But I did believe you (they, we, whoever) were trying to make HTML more
> XML-like, because it is far easier for a programmer to validate
> something with a symmetrical tag open-close structure than one where one
> end tag implicitly closes another completely different tag.

What "they" are doing to HTML isn't really on-topic for this
list, so I will address that part off-list.

> Now what you're saying is that it was actually invalid for me to OPEN
> that UL, not for me to later close it.

No, absolutely not : it was perfectly valid for you to open the <UL>,
but in so doing, you forced the <P> to close.

> Would that be a more 'human'
> interpretation of the spec? So your validator (and that in NetBeans IDE
> which I assume uses your schema and which is what led me here) has
> somehow detected the structural 'problem' before it identified the thing
> it believes is responsible for it. I don't get that - are you working
> through the file backwards or something?

No, see above.  The following is perfectly valid :

<HTML>
<HEAD>
	<TITLE>Hallo</TITLE>
</HEAD>
<BODY>
	<P>
		<UL>
			<LI>...</LI>
		</UL>
</BODY>
</HTML>

But it doesn't achieve what you set out to achieve; you simply
can't have a <UL> as a direct descendant of a <P>, because both
are block-level elements and these do not nest.

> So OK, the spec isn't really saying that one tag closes another, the
> validator just makes it look that way. Right? You'll restore this old
> desktop application hacker's faith in web-developer-kind if you say
> yes... :-)

No, your <UL> really does force the <P> to close, because
the DTD says that an End tag for <P> is optional; if it
were not for the latter stupidity, the diagnostic would
be much cleaner : something along the lines of

	"Block-level element UL cannot occur as direct descendant of block-level element P"

> Which brings me now to how to make equivalent valid HTML. How do I place
> a list directly into a paragraph? By that I mean I don't wish to have a
> paragraph break between the text and the start of the list (nor between
> the end of the list and subsequent text if applicable). In the past I
> would just do it with BR tags and double BRs between paragraphs, but I
> thought those were frowned upon now, again because they don't have an
> open-close form.

Well, they are frowned upon (except where they are necessary, such
as verse) but not because they are not containers; just because they
are frequently (ab)used to affect layout rather than structure.

But let's return to your real question.  You say "I don't wish to
have a paragraph break between the text and the start of the list"
and from this I suspect you are thinking visually : that is, you
don't want additional vertical white space between the text and the
start of the list.  Am I correct ?  If so, then you are using the
wrong tool to control this.  Spacing is (almost) nothing to do
with your HTML markup (except for default behaviours) and everything
to do with CSS.  So, if you want the following to have no vertical
white space between "text text</P>" and "<UL><LI>more text", then
you need to specify CSS rules for P and UL, to ensure that no padding
and/or margins intervene.

<HTML>
<HEAD>
	<TITLE>Hallo</TITLE>
</HEAD>
<BODY>
	<P>text text</P>
		<UL>
			<LI>more text</LI>
		</UL>
	<P>text text</P>
</BODY>
</HTML>

> Call me crazy but I would like if possible to accomplish this sort of
> basic text flow control without exploding my head trying to use a CSS or
> floating DIVs for my simple HTML help file that was only supposed to be
> a 5 minute job. :-)

Basically not possible.  All block-level elements (<P>, <UL>, <DIV>, ...)
are basically <P>-like, and when one follows another, the browser
will insert a certain amount of white space to indicate the boundary.
But it's pretty trivial to suppress it in CSS.  Compare and contrast
the two examples below :


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
	<TITLE>Hallo</TITLE>
</HEAD>
<BODY>
	<P>text text</P>
		<UL>
			<LI>more text</LI>
		</UL>
	<P>text text</P>
</BODY>
</HTML>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
	<TITLE>Hallo</TITLE>
	<STYLE TYPE="TEXT/CSS">
		P, UL {margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0}
	</STYLE>
</HEAD>
<BODY>
	<P>text text</P>
		<UL>
			<LI>more text</LI>
		</UL>
	<P>text text</P>
</BODY>
</HTML>

The proof is left to the reader as to why I did not write

	P, UL {margin: 0; padding: 0}

** Phil.

Received on Thursday, 10 March 2011 00:14:09 UTC