This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Stylesheets > April 2006 > text-align: "." fails...





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author text-align: "." fails...
kj

2006-04-25, 7:03 pm



I've tried *many* variations of the following:

<TABLE>
<TR><TD STYLE='text-align: "."; font-family: Courier'>0.12</TD></TR>
<TR><TD STYLE='text-align: "."; font-family: Courier'>10.1</TD></TR>
<TR><TD STYLE='text-align: "."; font-family: Courier'>123.001</TD></TR>
<TR><TD STYLE='text-align: "."; font-family: Courier'>0.02</TD></TR>
</TABLE>

but they all fail to produce a column of numbers lined up at the
decimal point. What am I doing wrong?

Thanks!

kj

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Jukka K. Korpela

2006-04-25, 7:03 pm

kj <socyl@987jk.com.invalid> wrote:

> I've tried *many* variations [ text-align: "." ]

- -
> but they all fail to produce a column of numbers lined up at the
> decimal point.


None of the variations works. Aligning on a character, though formally
possible both in HTML and in CSS, has never been implemented in browsers.

As a workaround, you could right-pad the numbers with zeros so that they have
the same number of digits to the right of the decimal marker, and just right-
align the cells. This will in practice align the numbers on the marker. You
don't need a monospace font for that, since in virtually all fonts used in
browsers, digits share the same width. (In typographical terms, the fonts
have "tabular digits".)

If you think right-padding with zeros is not correct (10.100 might be seen as
having more accuracy than 10.1), you could cheat a little with things like

<td>10.1<span class="z">00</span></td>

with

..z { visibility: hidden; }


--
Yucca, http://www.cs.tut.fi/~jkorpela/
Harlan Messinger

2006-04-25, 7:03 pm

Jukka K. Korpela wrote:
> As a workaround, you could right-pad the numbers with zeros so that they have
> the same number of digits to the right of the decimal marker, and just right-
> align the cells. This will in practice align the numbers on the marker. You
> don't need a monospace font for that, since in virtually all fonts used in
> browsers, digits share the same width. (In typographical terms, the fonts
> have "tabular digits".)
>
> If you think right-padding with zeros is not correct (10.100 might be seen as
> having more accuracy than 10.1), you could cheat a little with things like
>
> <td>10.1<span class="z">00</span></td>
>
> with
>
> .z { visibility: hidden; }


Too bad   (figure space) doesn't work.
Jukka K. Korpela

2006-04-26, 3:50 am

Harlan Messinger <hmessinger.removethis@comcast.net> wrote:

> Too bad   (figure space) doesn't work.


Well, it works in a few fonts in the intended sense, so it might have limited
applicability in some (generally non-WWW) situations.

Technically, the treatment of figure space, and other fixed-width spaces,
in rendering and otherwise, is _undefined_ according to HTML specifications.
In practice though they are treated as if they were graphic non-whitespace
characters, with all the problems that arise from the fact that their glyphs
might or might not be available in a font and might or might not match the
specified or suggested widths.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Harlan Messinger

2006-04-26, 7:06 pm

Jukka K. Korpela wrote:
> Harlan Messinger <hmessinger.removethis@comcast.net> wrote:
>
>
> Well, it works in a few fonts in the intended sense, so it might have limited
> applicability in some (generally non-WWW) situations.
>
> Technically, the treatment of figure space, and other fixed-width spaces,
> in rendering and otherwise, is _undefined_ according to HTML specifications.


Is it undefined in any way that's different from the way that handling
of, say, the letter "A" is undefined?

> In practice though they are treated as if they were graphic non-whitespace
> characters, with all the problems that arise from the fact that their glyphs
> might or might not be available in a font and might or might not match the
> specified or suggested widths.


What choice is there? I supposed the HTML engine could be made
responsible for determining the distance that a "9" in the current font
would span horizontally, including normal character spacing, and then
offsetting that far to the right, but that seems unreasonable. The
figure space ought to be in the font.
Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews