W3C home > Mailing lists > Public > www-html@w3.org > April 2000

Re: Ignoring empty paragraphs

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
Message-ID: <Pine.SGI.4.05.10004101336000.9788-100000@smaug.java.utoronto.ca>
 [ 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: &nbsp; 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:

2. -- 'transitional' DOCTYPE declaration

3. -- 'Strict" DOCTYPE declaration

Received on Monday, 10 April 2000 16:29:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:05:53 UTC