Forum Moderators: not2easy

Message Too Old, No Replies

Break-word?

How can I break long words

         

Joshie76returns

10:35 am on Oct 16, 2005 (gmt 0)

10+ Year Member



Is there a way I can use CSS (cross-browser) to force very long words to break if they reach the container edge - rather than stretch the container?

It's for a technical article and contains some encrypted strings that are enormous things that have no natural break: ASDOIFODIOISDFNKKERKWASDIASDFIUSADFKSADQFJKSJDF etc...

doodlebee

8:35 pm on Oct 16, 2005 (gmt 0)

10+ Year Member



If you set a definite width for the container, it shouldn't stretch, However, sometimes it will in IE or Mozilla (I forget which).

#container { width: 200px!important;
width:200px;}

the!important statement tells Mozilla that it's important that this container stay at 200px wide. IE, however, will ignore the line if you don't reiterate it.

createErrorMsg

9:14 pm on Oct 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE, however, will ignore the line if you don't reiterate it.

IE will ignore it anyway. IE's autoenclosing behavior causes it to expand a container to hold the content whenever that content is wider than the container. The only way to turn this behavior off is to prevent hasLayout from being triggered, which is impossible if any sort of dimension, or about half a dozen other properties, are involved.

Defining a width will prevent FF from stretching the container, but the uninterrupted string will just spill out of the container, which can be just as bad, and is at least just as unsightly.

Check out this thread [webmasterworld.com], specifically msg#6 by Bonusbana. He provides a PHP script that might be of some use. One way or the other, you're going to have to split that long string, beit manually or with a script.

cEM