Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • What happens when the pixel width occurs within the space of a letter (say half-way through an 'm')? Do you expand the string to include the full 'm', or round it down to omit the 'm'? Oh, and no, there isn't a built in JS function for this, though CSS does it quite easily. Commented Jul 27, 2011 at 17:34
  • 5
    Just out of curiosity, what's your application for this? You could easily just let the string overflow it's container but use overflow: hidden. Commented Jul 27, 2011 at 17:34
  • @David Thomas: I will omit the 'm' in that case. Commented Jul 27, 2011 at 17:36
  • @CrazyJugglerDrummer: I am aware of the overflow: hidden property. however, it is not sufficient in this case because I am adding ellipsis to an overflowing word and text-overflow: ellipsis is not supported in mozilla Commented Jul 27, 2011 at 17:37