Actually,
Another problem is that different browsers are probably going to react very differently to the problem. I know that IE has some problems in this regard (expanding boxes to fit the contents), but I don't know if it will apply directly to you. You could also look at maybe using min-width and max-width properties, so that the box has some room to change size?
Hi Kevin,
On the face of it looks likes dayveday was onto something. Zero-width spaces seem to be the most simple & cross-browser solution as follows:
(I'm afraid I haven't tested on Safari or Opera, just IE & Firefox. If anyone would like to check out the support on other browsers then please do!)
<wbr> is not supported by later Mozilla & Firefox, so unfortunately that's out of the picture. Although Moz tends to break CSS layout less with long words, flowing out of the containing box rather than expanding it to fit the text, so I suppose it could be a quick 'n' dirty solution...
I thought I'd found a solution using soft hypens (the most semantically-correct way do do this) but strangely, these are not supported by Moz either.
So if you take dayve's original idea but code the character as unicode rather than  then long words do word-wrap in both Firefox and Internet Explorer! And different character sets don't matter quite so much either.
Now I need to work out how to only apply the zero-width space to long words, not just randomly throughout the text. Kevin, are you using php or Javascript? I originally thought you posted your code in php (hence my earlier posted suggestion) but I'm thinking your code is actually a scrap of JS, am I right?
Cheers,
fuzzy
Oh, yes.
I am using JavaScript. And I need it to be JavaScript. I now PHP would be much simpler...
I just wanted to make something like a chat... And everything is fine except for... this.
I thought there was a simple, clean elegant way of solving this... but by what I read and here, its not that simple...
I guess what I did "works" and I dont really need that much more for what i am doing now.
When I finish the application I let you know. If its very successful we might have to find a nicer way to fix this.
THANKS FOR YOUR HELP!!!!!
Kevin