Re: CSS2.1 Various Inline-related Stuff

Ian Hickson wrote:
> 
> On Mon, 2 Sep 2002, fantasai wrote:
> >
> > I know we've gone over this before, but you never told me *why*
> > this empty-string-generates-inline-box behavior is useful. I
> > think it's just confusing.
> 
>    <foo></foo>
> 
> ...is empty per XML -- it contains nothing ('none'). It is defined as
> being the same as:
> 
>    <foo/>
> 
> If foo is a block, then it has no line box contents, per CSS.
>
> Now, using the DOM, add an empty text node (""). Per XML, I think the
> closest we can get to serialising that is:
> 
>    <foo><![CDATA[]]></foo>
> 
> This is not empty.

I thought CDATA sections, once parsed, result only in the character
data they contain, but then, you know more about SGML/XML rules than
I do. Anyhow, supposing it is--

> If foo is a block, then it has a line box, per CSS, because it has
> inline content (an empty anonymous inline).

Which brings the question, what sort of content generates an 
anonymous inline in CSS?

div {border: 1px solid}


Does this?

  <div></div>

A non-EMPTY element doesn't get any emptier.


Does this?

  <div><!--comment--></div>

Comments can be nodes in the DOM, but they're /comments/, and comments
about the code really shouldn't affect the presentation. Depending on
the markup processor, the comment might not even exist beyond the
parsing stage and thus won't get to the CSS layout part.

A variation:

  <div><?target ?></div>

The processing instruction, on the other hand, must get passed through.


There's, this, too--

  <div>  </div>

('white-space' is not 'pre', but a text node exists in the DOM)


And this--

  <div>
    <p>A paragraph.</p>
  </div>

Does the whitespace here create anonymous boxes?
(The CSS2 spec very sneakily put text before and no </p> after their
 paragraph so I can't say for sure.)

> I'm not saying this is useful. I'm just saying that's the way it is.

The CSS formatting model is not, AFAIK, defined as a visual representation
of the DOM. So why is this the way it is?

> Extending this to 'content', you have:
> 
>    element has text content         content: 'bar'
>    element has empty text content   content: ''
>    empty element                    content: none
> 
> For an inline element, the last one is indistinguishable from the middle
> one, since the inline itself is in a line box already. Hence the hoops to
> get it to make display:none.

'it' being restricted to make "display: none" only for :before/:after,
I hope.

~fantasai

Received on Tuesday, 3 September 2002 03:06:36 UTC