http://qs321.pair.com?node_id=460430


in reply to module to measure string in pixels

I thought if there is any way to measure the expected length in pixels with Perl. You guys know of any?

That information isn't available on the server side, since the server doesn't have knowledge of what fonts the user has installed on the client side, and browsers do font substitution if the requested font isn't available.

What you could do is use CSS to specify a fixed-width font for the option text. Something like (untested):

<style type="text/css"> #form_s option { font: "courier new", monospace; } </style>
then you can line up your text by counting characters.