Do you know a good cross-browser way to find out how wide the text string will be so that you can split it exactly so that it matches a fixed width?
Suppose you want to break long text, for example, so that it does not overflow the container with a fixed width, but you want the line to break the proximity to the border, so guess where to insert & shy; s is not a clean solution.
I want to research, I suppose it can be done with an invisible div, and then print a line inside it and check the width of the div or something like that with Javascript.
Has anyone done something like this?
* (focus is not word wrap, it's just an application that comes to my mind right now, but knowing the width of the text is what I want)
source
share