Counting characters is a solution, but you would have to take characters' width into account.
'W' is wider than 'i', unless you're using fixed-width fonts.
Moreover, you cannot guarantee that font of your choice will be available in client's browser, that his font-size settings will be same ar yours, etc.
You can, however, combine two solutions - first, approximate font-size using some character-counting algorigthm, for example - assume that characters have fixed width, and then correct your calculations with client-side js, if js determines that line has been split anyway.
It'll require some tuning, but I believe acceptable results can be achieved.
answered 2009-07-24T12:38:12.233