[thelist] Is there a way to calculate what the width of a displayed word?

Christian Heilmann codepo8 at gmail.com
Mon Oct 17 12:08:38 CDT 2005


> I have a list of words, any of which can be displayed within a bordered div.
> I want the bordered div to stay the same width no matter which word is in
> it, short or long.
>
> I imagine I can make the bordered div be an absolute width the size of the
> longest word in the list (unfortunately the font I am dealing with isnt
> monotype). How can I calculate what the widths of the longest word is?
>
> Anyone have experience doing this?

If this is not about generating images, then there is no chance for
you to do that, as the visitor is always able to resize the font to
his/her needs (in good browsers).

If you want to make sure a button does not get too wide, you _could_
generate an image or a flash file.

--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/


More information about the thelist mailing list