[css3-text] letter-spacing at element boundaries

The current WD says,[1]

  "At element boundaries, the total letter spacing between two characters is given by and rendered within the innermost element that <em>contains</em> the boundary."

AIUI, this means that in the example

  <p>The quick <span style="letter-spacing:1em">brown</span> fox</p>

we should have no extra spacing (beyond the standard word-space) before or after the word "brown", because the boundaries <space, letter b> and <letter n, space> are not _contained_ by the span that has the letter-spacing, but only by the <p> element. So the expected rendering is something like this:

  The quick b    r    o    w    n fox

(Correct?) However, I think from an author's point of view, it would be more natural to have a somewhat different rule, such that in this example, the word spaces before and after "brown" _would_ be affected:

  "At element boundaries, the total letter spacing between two characters is the mean of the letter-spacing property of the characters on each side of the boundary."

This would add 0.5em to the word spaces each side of "brown" in the above example:

  The quick   b    r    o    w    n   fox

My thinking is that conceptually, letter-spacing is equivalent to modifying the sidebearings of the glyphs (like kerning but in a uniform way rather than for specific glyph pairs), and it is most natural to think of this as happening equally on both sides of the glyph - so the left and right sidebearings are each adjusted by _half_ of the letter-spacing value. From this, it follows naturally that at a boundary, the effective total change to inter-glyph spacing is one-half of the letter-spacing of the left-hand glyph _plus_ one-half of the letter-spacing of the right-hand glyph; or in other words, the mean of the letter-spacing properties of the glyphs on each side.

Of the browsers I tested (fairly recent versions of Firefox, Safari, Chrome, IE9, Opera), only IE9 appeared to implement the behaviour as currently specified,[4] so I don't think there'd be a major backwards-compatibility issue with modifying this in the spec, if we decide it would be better.

I also noticed that fantasai seemed to think[2] back in 2005 that this would be the appropriate behaviour. However, a later comment[3] chose a different behaviour. I'm interested to know whether that was a decision driven by specific needs/use-cases, or would it be worth reconsidering?

JK

[1] http://www.w3.org/TR/2012/WD-css3-text-20120119/#letter-spacing
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=299943#c3
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=299943#c11
[4] Though even IE9 failed to follow the spec in other aspects of letter-spacing

Received on Monday, 30 January 2012 22:02:08 UTC