Calculate length of user input to prevent overflow when outputting in div
<p>I am reading a string my user is inputting via PHP and I need to spit it back out in a div tag. This div tag has a width of 500px. If the user enters a word that is too long, the word will overflow the container. If the user enters two words that are almost two long, it will split into two lines.</p>

<p>My question is how do I determine if a word is too long or not? I have tried setting a character count, which is not an accurate representation of length as certain characters (ie W and I) have different widths. Is there a solution?</p>

<p>My current algorithm is to break the user input into chunks, each of 40 characters, and output it.</p>
