Forum Moderators: open

Message Too Old, No Replies

Word Wrap

Forcing a browser to break a word

         

ggrot

12:05 am on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE 5.5+ has a cute little css property called word-wrap. You can set it as:
word-wrap:break-word;

This will force the browser to break long words in the middle of the word if need be, such as user posted urls or something, keeping tables and frames the right size.

I can easily write server side software to break words apart at certain character lengths, but if you add in different fonts, font sizes, bold, italic, and non-fixed width fonts, it becomes a nightmare to get it as close to the right edge as possible before a break.

Do you know of any easy way of performing this same css functionality within say, opera?

ergophobe

12:29 am on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



HTML 4 officially has a soft-hyphen entity

numeric: ­ ( & # 1 7 3 ; )
named: ­ ( & s h y ; )

Only IE6 supports this according to my tests. You might be able to get other clients to apply it with a specific character encoding and using the Unicode (U+00AD) for it, but I doubt it.

See

[w3.org ]

[w3.org ]

[microsoft.com ]

<edited to remove accidental smilies>

(edited by: tedster at 12:40 am (utc) on May 3, 2002)

ggrot

4:45 am on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That still forces me to know where I want to break the words server side so i can insert the soft hyphens. Ideally I could throw in any text and if a word was longer than the table/window, it would break automatically when it hit the end of table/window.

ergophobe

5:30 pm on May 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, how much text are you talking about? If it's a small amount and you really don't want to control where it breaks, every other character could be a soft hyphen. Apart from the fact that this will quintuple the size of the file (a becomes ­a), it seems like readibility is going to be a problem if the words break randomly, won't it?

What is it exactly that you're trying to do(could you post some sample text?). Perhaps instead of HTML, you are looking for CMS - that's the Chicago Manual of Style for those who live exclusively in the post-print world :-)

Tom