[CSS21] Clarifications to run-in

The current spec, which was updated in response to some previous issues, reads:

   # A run-in element (or pseudo-element) A behaves as follows:
   #
   #   1. If A has any children that inhibit run-in behavior (see below),
   #      then A is rendered as if it had 'display: block'.
   #   2. Let B be the first of A's following siblings that is neither
   #      floating nor absolutely positioned nor has 'display: none'.
   #      If B exists and has a specified value for 'display' of 'block'
   #      or 'list-item' and is not replaced, then A is rendered as an
   #      'inline' element at the start of B's principal box. Note: A
   #      is rendered before B's ':before' pseudo-element, if any.
   #      See 12.1.
   #   3. Otherwise, A is rendered as if it had 'display: block'.
   #
   # In the above, "siblings" and "children" include both normal elements
   # and :before/:after pseudo-elements.
   #
   # An element or pseudo-element C inhibits run-in behavior if one of
   #  the following is true. (Note that the definition is recursive.)
   #
   #   1. C is not floating and not absolutely positioned and the computed
   #      value of its 'display' is one of 'block', 'list-item', 'table'
   #       or 'run-in'.
   #   2. C has a computed value for 'display' of 'inline' and it has one
   #      or more children that inhibit run-in behavior. (Where "children"
   #      includes both normal elements and :before/:after pseudo-elements.)

It's painfully explicit about certain things that should be specified
clearly in a general sense, and not called out specifically here.

Calling them out here implies that there are ambiguities everywhere
they are not mentioned.

1. The most obvious one here is the distinction between elements and
    pseudo-elements, which was recently clarified in 5.12.

2. The other is the mention of ignoring "display: none" elements,
    which are already specified to be taken out of the formatting tree.
    (If that's not clear enough generally, then we should fix that
    generally and not specifically, because not ignoring them would
    break most of the formatting algorithms in the spec: table layout,
    margin collapsing, etc.)

Other problems with this section include
   - Issue 198 http://wiki.csswg.org/spec/css2.1#issue-198
   - Undefined interaction of run-in with inside marker boxes.
   - Note about :before should be normative.

Taking advantage of the clarifications from Issue 120 (more rigorous
definitions for "block" and "inline" terms) and Issue 184 (clarify
that pseudo-elements are treated like real elements except...),
here are some proposed changes:

Replace
   #   2. Let B be the first of A's following siblings that is neither
   #      floating nor absolutely positioned nor has 'display: none'.
   #      If B exists and has a specified value for 'display' of 'block'
   #      or 'list-item' and is not replaced, then A is rendered as an
   #      'inline' element at the start of B's principal box. Note: A
   #      is rendered before B's ':before' pseudo-element, if any.
   #      See 12.1.
with
   |  2. Let B be the first of A's in-flow following siblings. If B
   |     exists and is a non-replaced block box, then A is rendered
   |     as if it were an 'inline' element at the start of B's contents--
   |     after B's list marker box, if any, and before B's ':before'
   |     pseudo-element, if any. (See Chapter 12.)

Remove
   # In the above, "siblings" and "children" include both normal elements
   # and :before/:after pseudo-elements.

To generalize the last rule to work with new CSS3 display types, replace
   #   1. C is not floating and not absolutely positioned and the computed
   #      value of its 'display' is one of 'block', 'list-item', 'table'
   #       or 'run-in'.
with
   |   1. C generates an in-flow block-level box or has a computed 'display'
   |      value of 'run-in'.

Replace
   #   2. C has a computed value for 'display' of 'inline' and it has one
   #      or more children that inhibit run-in behavior. (Where "children"
   #      includes both normal elements and :before/:after pseudo-elements.)
with
   |   2. C is a non-replaced inline element and has one or more children
   |      that inhibit run-in behavior.

~fantasai

Received on Friday, 17 September 2010 00:42:10 UTC