Web Hosting Talk







View Full Version : CSS to move long text to next line?


lexington
09-08-2008, 10:15 PM
Hello, is it possible to use CSS to move long characters that do not have spaces inbetween them to the next line? I am using an HTML td row and as a test I added really long text like "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" and since the letters are all together it stretches the table. I was curious to know if css can move that long line of text to the next line. Please provide a working example and thanks!

lexington
09-09-2008, 01:38 PM
No one knows? I think it is possible since a friend of mine was able to make css cut off any text that goes beyond the site dimensions of the div.

awatson
09-09-2008, 02:16 PM
You can cut it off by setting a fixed width and overflow:hidden; on the containing element.

As far as I know there's no way to "break" the long words like you're looking for. You could do it server-side without too much trouble.

oliviakitty
09-09-2008, 10:23 PM
Try this...


pre {
white-space: pre-wrap; /* css-3 */

white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */

hite-space: -pre-wrap; /* Opera 4-6 */

white-space: -o-pre-wrap; /* Opera 7 */

word-wrap: break-word; /* Internet Explorer 5.5+ */
}

Slitheryimp
09-09-2008, 11:12 PM
Is using Soft Hyphen a solution?

In HTML, there are two types of hyphens: the plain hyphen and the soft hyphen. The plain hyphen should be interpreted by a user agent as just another character. The soft hyphen tells the user agent where a line break can occur.

Those browsers that interpret soft hyphens must observe the following semantics: If a line is broken at a soft hyphen, a hyphen character must be displayed at the end of the first line. If a line is not broken at a soft hyphen, the user agent must not display a hyphen character. For operations such as searching and sorting, the soft hyphen should always be ignored.

In HTML, the plain hyphen is represented by the "-" character (- or -). The soft hyphen is represented by the character entity reference ­ (­ or ­)

http://www.w3.org/TR/html401/struct/text.html#h-9.3.3