Re: 14.2.1 'background-position' - block level only?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>> From Section 14.2.1 of the CSS2 spec. [1]

>>>  'background-position' 
>>> Value:  [ [<percentage> | <length> ]{1,2} |
>>>           [ [top | center | bottom] || 
>>>           [left | center | right] ] ] | inherit  
>>> Initial:     0% 0%  
>>> Applies to:  block-level and replaced elements  
>>> Inherited:   no  
>>> Percentages: refer to the size of the box itself  
>>> Media:       visual  
>> 
>> Notice the "Applies to" says it's only for block-level and replaced
>> elements. However, all the other background properties, in particular
>> background-repeat, apply to everything. So, how do we get a single 
>> image to appear behind some inline text?
> Since all other background properties apply, the background image
> should still appear behind -- but there is no way to indicate
> preferred position of the background image. 
So the results are undefined? The spec certainly doesn't say where to start
drawing a tiled backdrop onto a broken line box.

>> The problem which can come up is what to do with broken line boxes.
>> 
>> WinIE4 supports 'background-position' even with inline elements
>> (over-support of the spec?!), and gets around the problem by simply not
>> drawing the background if the line box splits.
>> 
>> I suggest the 'background-position' property be expanded to apply to
>> everything, with behaviour at line breaks being left up to the UA
designer.
> So you would treat the first line box as a block-level element, and
> the background position would be undefined for the rest of the line
> boxes? That sounds reasonable. 
Undefined only if the line box spreads over more than one line. If the line
box is rectangular, then there is no problem, it can be treated like a
block box would (as far as positioning the image is concerned, anyway).

> Here are some alternatives:
> - leave it as is since it's too late to enforce interoperability 
It's impossible to "enforce interoperability" anyway. I suggest we classify
it as an error in the original spec and put an agreed modification on the
errata page. HTML4 has had loads of such changes, some minor, some less so
(in fact, HTML4 was republished in April, with the errors found at the time
corrected. I suppose it could be called HTML4 SP1 or HTML4.01..).

>    and there's no single obvious good solution
What IE4 currently does is IMHO better than what the spec states, so that
could be taken as the improvement.

> - say that background-attachment on inline elements is relative to
>   the containing block (which is CSS2-speak for (in most cases) the
>   "parent element")
No. This is counter intuitive at best.

> - say that background-attachment on inline elements is relative to
>   the respective line boxes that are created.

This is what I would recommend.

When 'background-position' is applied to block level elements, then the
background image should be placed according to the behaviour currently
described in the CSS2 spec (i.e. relative to the upper left corner of the
box's padding area).

When 'background-position' is applied to an inline element whose line box
is unbroken (for example a one word CITE) then the background image should
be placed according to the behaviour currently described in the CSS2 spec
for block level elements (i.e. relative to the upper left corner of the
box's padding area).

Finally, we have the situation of when 'background-position' is applied to
an inline element whose line box is broken by a line break. 

Examine the diagram at the end of section 9.4.2 [2], reproduced here
courtesey of not-a-gif II (tm): [3]

  |         .............|
  | Several : emphasized |
  |........ '''''''''''''|
  | words : appear here. |
  |''''''''              |

There are several possibilities.

 - Do it the same way as the above, taking the 'upper left' corner of the
box's padding area to be where the upper left corner of the border would be
drawn (in this case above the 'e'), and treating the broken line box to be
an irregular viewport into a rectangular area where the background is
drawn:

            +--- call this the upper left 
  < -ve <  \|/   corner of the box's padding.
  |         x............|
  | Several : emphasized |
  |........ '''''''''''''|
  | words : appear here. |
  |''''''''   > +ve >    |
            

 - Work out the smallest rectangle that encloses all parts of the broken
inline element and call the upper left corner of the box's padding area the
upper left corner of the surrounding box, then treat the broken line box to
be an irregular viewport into _this_ rectangular area:

   +--- call this the upper left 
  \|/   corner of the box's padding.
  |x--------.............|
  ||Several : emphasized |
  |........ '''''''''''''|
  | words : appear here. |
  |''''''''              |

 - Recommend one of these options, but say that support is optional.

 - Say that the upper left hand corner is undefined for broken line boxes.

(these last two are really different ways of saying the same thing).

I prefer the first of the four.

[1]: http://www.w3.org/TR/REC-CSS2/colors.html#propdef-background-position
[2]: http://www.w3.org/TR/REC-CSS2/visuren.html#inline-formatting
[3]: Well, it would be a normal not-a-gif [4] but that requires CSS and
there is no CSS in ASCII...
[4]: http://css.nu/pointers/#TM

- -- 
Ian Hickson - visit web page for geek code
http://www.bath.ac.uk/~exxieh/
PGP Public Key available on main PGP servers. Fingerprint:
85F7 0D50 A3D1 82AE 4F81  16D4 9670 02D4 7290 F4E0

-----BEGIN PGP SIGNATURE-----
Version: PGP 5.5.5
Comment: My web site is at http://www.bath.ac.uk/~exxieh/

iQA/AwUBNfRlxJZwAtRykPTgEQILFACeIQmCfXet9a4e2SiL/pQyNuEHLegAoJkT
fIaPwsh9WlAo9GXNiZZAFci8
=HDho
-----END PGP SIGNATURE-----

Received on Monday, 7 September 1998 19:17:46 UTC