W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Re: % is not a valid unit for border-width

From: L. David Baron <dbaron@dbaron.org>
Date: Thu, 5 Jan 2012 20:31:11 -0800
To: Matthew Wilcox <elvendil@gmail.com>
Cc: Lea Verou <leaverou@gmail.com>, www-style@w3.org
Message-ID: <20120106043111.GA3790@pickering.dbaron.org>
On Thursday 2012-01-05 16:33 +0000, Matthew Wilcox wrote:
> It might just be my mis-understanding the language of the
> specification in that case (not helped by the fact that the spec
> simply says "etc" instead of actually listing the valid units or
> linking to a list of valid units, lazy writing).
> I think % in fluid designs makes perfect sense, I don't feel that is
> hacky at all - it's basically a really limited form of math (which CSS
> is desperate for).
> So we're agreed that % on border-width makes sense both practically,
> semantically, and from a consistency standpoint?

In Gecko, and possibly in other implementations, rounding and
pixel-snapping of border widths behaves differently from rounding
and pixel-snapping of other things (margin, padding, width, height).
This is because, for borders, authors care about consistency of
width:  a border looks very bad if it's different widths on
different sides.  For example, Gecko makes a border specified as
1.6px (which might, say, have been 0.1em) be 1px on all sides.  For
the other things, we do layout at a sub-pixel scale and then snap
each *edge* to pixel boundaries.  (If we did this for borders, the
1.6px border would be 1px in some places and 2px in others,
depending on what subpixel position it was positioned at.) This
pixel snapping means that, for example, elements of 25% width always
add to 100% (rather than sometimes a pixel more or less).

So if we want to introduce percentages to borders in a way that will
produce expected results in fluid designs, we'd need (unless there's
a solution that I'm not aware of) to sacrifice something else:
either consistency of border widths (i.e., different sides of a box
with the same specified border width will have borders occupying
different numbers of pixels) or things-adding-to-100% (which isn't
much good for fluid designs).

So I'm a little skeptical, and I think if we do this we should
probably think about specifying rounding and pixel-snapping behavior
in CSS (given how much Web sites depend on it).


𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                           http://www.mozilla.org/   𝄂
Received on Friday, 6 January 2012 05:52:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:09 UTC