How can you display a long string, website address, word or set of symbols with automatic line breaks to keep a div width? I guess a wordwrap of sorts. Usually adding a space works but is there a CSS solution such as word-wrap?
For example it (very nastily) overlaps divs, forces horizontal scrolling etc. wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
What can I add to the above string to fit it neatly within a few lines in a div or within the browser window?
This question has been asked here before:
Long story short:
As far as CSS solutions go you have: overflow: scroll;
to force the element to show scrollbars and overflow:hidden;
to just cut off any extra text. There is text-overflow:ellipsis;
and word-wrap: break-word;
but they are IE only (break-word
is in the CSS3 draft, however, so it will be the solution to this 5 years from now).
Bottom line is that if it is very important for you to stop this from happening with wrapping the text over to the next line the only reasonable solution is to inject ­
(soft hyphen), <wbr>
(word break tag), or ​
(zero-width space, same effect as ­
minus hyphen) in your string server side. If you don't mind Javascript, however, there is the hyphenator which seems to be pretty solid.