W3C home > Mailing lists > Public > www-style@w3.org > December 1999

Re: CSS character width unit missing: an oversight, methinks?

From: Peter S. Linss <peter@linss.com>
Date: Sun, 05 Dec 1999 16:48:53 -0800
Message-ID: <384B07F5.6EE5E00@linss.com>
To: Nils Klarlund <klarlund@research.att.com>
CC: www-style@w3.org
Nils Klarlund wrote:

> I have taken CSS quite seriously as a formatting model for typesetting
> or pretty-printing programming notations*.
> I need a way of indenting a div-box an amount of space that is a
> multiple of the character-width (I'm using a bold, fixed-with font).

In the Mozilla engine you can use the 'ch' unit. ie:
div { width: 80ch; }

This only works for certian horizontal measurements (I seem to remember
only widths, but I could be wrong) and only when there is a fixed width
font in effect for the formatting object, otherwise it is ignored.

I believe this has been proposed (at least informally) for CSS3. You can
take this as a formal proposal if you want...


> Unfortunately, this is not possible since there is no way of referring
> to the width of a character in CSS (em and ex don't give me the
> width). A fundamental, little, or inconsequential oversight in CSS?
> (I fake it by using ex and a multiplier in my XSLT; a certain value
> gives near-optimal results in IE5, Netscape 4, and Mozilla.)
> More generally, I would like a mechanism that allows me to use the
> width of a box X as a width parameter of box Y.  Setting box X with
> visibility:hidden doesn't give me a method of extracting its width.
> (As far as I can tell.)
> /Nils
> *) See http://www.brics.dk/DSD/dsd2html.html for a very long XSLT
> description of how to produce nice-looking HTML from abstract syntax
> trees.

Received on Sunday, 5 December 1999 19:49:28 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:26:52 UTC