W3C home > Mailing lists > Public > www-style@w3.org > November 2010

[CSS21] 16.1: percentage text-indent (two minor issues)

From: Peter Moulder <peter.moulder@monash.edu>
Date: Wed, 03 Nov 2010 14:39:02 +1100
To: www-style@w3.org
Message-id: <20101103033902.GA8065@bowman.infotech.monash.edu.au>
My best literal reading of the spec is that percentage text-indent for a
block container box B is calculated relative to the containing block of B,
rather than to the content width of B itself.

All user agents I've tested do this for the case that B is a normal
block box, but if B is a table cell then gecko calculates relative to B's
content width, whereas all other user agents I've tested calculate relative
to B's containing block width, i.e. the table width (content width of the
outer table box).

I think that readers may well have the intuition that the indentation is
"contained by" the block to which the 'text-indent' property is associated,
so might expect percentages to be relative to B's content width; and I'd
have thought that B's content width would be more useful.

Thus, even if we resolve that it should indeed be relative to the width of
the containing block of B, I suggest that the spec should at least draw
more explicit attention to this.

A second issue with percentage text-indent (say when specified on a
child of a table-cell) is that it complicates the calculation of a cell's
“minimum content width” and “"maximum" cell width” for purposes of
automatic table layout (§ and the related (typically assumed
synonymous) corresponding concepts of “preferred minimum width” and
“preferred width” for purposes of shrink-to-fit width (§10.3.5).

All of those calculations are marked as non-normative (e.g. "CSS 2.1 does
not define the exact algorithm"), so technically no change is required,
but I think it worthwhile drawing authors' attention to the fact that
"Using a percentage value for 'text-indent' may make [[shrink-to-fit]]
widths and automatic table layout widths less predictable, and might
result in overflow".

(Overflow does indeed occur in common user agents, particularly for
single-line cells/floats where the width is based on the miscalculated
"maximum" / "preferred" width.  The suggested wording "might" above is
chosen with the intention of conveying what some user agents do, while
trying to avoid sanctioning this behaviour.)


<title>What are text-indent percentages calculated relative to?</title>
<p style="width:200px; border:1px blue solid; text-indent:50%;">Text.</p>
<p>Result: Really is relative to containing block rather than the block, in Gecko, Konqueror, WebKit.</p>
<hr />
<div style="display:table; border-spacing:50px 0px; border:1px solid red;">
<div style="display:table-row;">
<div style="display:table-cell; width:150px; text-indent:50%; border:1px blue solid; border-right-width:50px; padding-right:50px;">|</div>
<div style="display:table-cell;">.....................</div>
<hr />
<table style="border:1px solid red;">
<td style="width:150px; text-indent:50%; border:1px blue solid; border-right-width:50px; padding-right:50px;">|</td>
<p>Result: Relative to cell content width in Gecko.<br />
Relative to table width in Konqueror &amp; WebKit.</p>
Received on Wednesday, 3 November 2010 03:39:33 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:40 UTC