i have text that i need to put in an html table lets say. i know the table is say 400 px wide. the text is somewhere between 10 and 40 characters and it will usually fit in the 400 px wide table. however, sometimes the text is too long and either wraps to the next line or widens the table. for example the lengths of these to strings are both 15 but the first is ‘longer’:
so is there any way to determine the actual pixel length of the string so that i can nicely chop off the end and replace is with elipsis. the only way i can think of doing this is to hardcode in values for the width in pixels of each character and thenuse this info to determine the length in pixles of the entire string. this is bad though because its font and font size dependent.
a good example of what i want is on this forum - notice how thread topics nicely fit in their respective cell and are sometimes ended with elipsis.