RE: BR element and generated content

Great, this is exactly the kind of definition I am for. Thanks!

Now with this definition of IMG and BR, adding before/after adds content to anonymous inline box within same background and border - that's what you'd expect, right?

Would be great to see this text in CSS3 Generated Content. You are listed as the only editor - do you intent to be updating it or is the spec in need of an owner?

-----Original Message-----
From: Ian Hickson [mailto:ian@hixie.ch]
Sent: Friday, October 12, 2007 3:15 PM
To: Alex Mogilevsky
Cc: fantasai; www-style@w3.org; Markus Mielke; Saloni Mira Rai; Arron Eicholz
Subject: RE: BR element and generated content

On Fri, 12 Oct 2007, Alex Mogilevsky wrote:
>
> I don't think this is just about BR.
>
> My reasoning for defining BR behavior is like this:
> * BR is defined in HTML as an empty element. It can't have any content.

That's just an authoring requirement. It's trivial to add content to a
<br> element, either using XML, or via the DOM:

   var br = document.createElement('br');
   br.appendChild(document.createTextNode('test'));


> * Then a rule like
>         br:before { content:'\A' }
>   puts content inside BR.
>
> * But at this point I don't know what to do with it, since BR must be
> empty. It is not valid to have content inside it, and if it manages to
> get some what is it supposed to do with it?

Just treat BR elements the same as any random inline element. The fact
that <br> elements can't have content is the same as the way that <ul>
elements can only contain <li> elements -- but that doesn't stop browsers
handling arbitrary content in <ul> elements. From a CSS point of view, all
elements apart from replaced elements are the same.


> Same issue applies to all other elements which either empty or have
> special rendering rules, e.g.
>
> <img>, <hr>, <tr> or <iframe>.

<img> in CSS3 could be similar to <br>:

   img { content: attr(src, url), attr(alt); }
   br { content: "\A"; white-space: pre; }

<tr> is not special at all, it just has display: table-row and renders
according to the table model.

<hr> and <iframe> are special from a CSS point of view. <hr> is especially
special. <iframe> is just a replaced element whose content comes from a
DOM property (contentWindow) instead of an attribute. Note that <iframe>
in HTML does contain contents, you just ignore them when rendering.


> Try the attached example with different browsers and you'll see wildly
> different effect.

Generated content's interaction with form controls is underdefined.
However, generated content's interaction with table elements is well
defined, and I see no reason why its interaction with <img> and <br> can't
be well-defined too, especially if we go the proposed route with defining
those elements using 'content' on the elements.

--
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 12 October 2007 22:49:36 UTC