- From: Ian Graham <igraham@smaug.java.utoronto.ca>
- Date: Mon, 10 Apr 2000 16:29:47 -0400
- To: Matthew Brealey <webmaster@richinstyle.com>
- cc: www-style@w3.org, www-html@w3.org
[ I'm CC'ng this over to www-style, since this thread has
raised the idea of a new CSS pseudo-class for identifing
empty elements.... ]
On Mon, 10 Apr 2000, Matthew Brealey wrote:
> Ian Graham writes:
> > I think Jason's idea of an :empty pseudo-class is the most appropriate way
> > of handling the rendering issue.
>
> Haven't you read my reply to that? It isn't necessary - margins
> collapse.
This assumes that the only thing you want to do is collapse margins,
which I believe is not the case (see later).
>
> > Indeed, you then have much finer control
> ....
>
> I think you mean P:empty + P:empty and div:empty + Div:empty.
Yes, you're right .
> However,
> as explained this isn't doing anything - in fact in current
> implementations you need to disable 'ignoring' (i.e., margin collapsing)
> of Ps, by making the element non-empty so that margins cannot collapse;
> ways of doing this are: to create a line box so that the element
> is not empty; <br> for the same reason; padding, border, or height.
This assumes that I always want margins to collapse, and that may
not be the case. I may, for example, want empty <p>'s or <div>'s to be
displayed as editable boxes, or to be represented by non-collapsed
boxes with generated content, or whatever.
The issues I see are as follows:
1) Should the HTML parser prune empty elements from the tree?
(David Baron's original question) I argue no, since this
is inconsistent with what I believe a parser should do.
At worse, a parser should 'correct' the parse tree to fix it
(e.g., by closing impropoerly closed elements) -- it should
never remove structure.
2) Should CSS selectors be able to _identify_ 'empty' elements --
that is, elements that are empty by definition or empty
because they contain only white space.
I argue that (2) might be useful because you would then be able to
define formatting properties, like collapsed empty <p>'s, but for
any element that is 'empty'.
This would also mean that the HTML renderer wouldn't need
special built-in rules for formatting empty <p>'s (the rules
would be defined in a style sheet) -- and also means such
rules could be defined for XML data.
Also, I can imagine cases where you wouldn't want the
elements to collapse -- for example, if the app were a WYSIWYG
browser/editor rendering a "template" HTML page, and the
paragraphs were template components to be edited and filled in.
I constructed three little test documents to look at how the
various browsers render empty block elements and adjacent "empty"
elements (these may duplicate some of your tests, Matthew).
These are found at:
1. -- no DOCTYPE declaration:
http://www.java.utoronto.ca/~igraham/html-tests/zero.html
2. -- 'transitional' DOCTYPE declaration
http://www.java.utoronto.ca/~igraham/html-tests/zero-loose.html
3. -- 'Strict" DOCTYPE declaration
http://www.java.utoronto.ca/~igraham/html-tests/zero-strict.html
Ian
Received on Monday, 10 April 2000 16:29:56 UTC