File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Word wrapping long text without whitespaces Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Word wrapping long text without whitespaces" Watch "Word wrapping long text without whitespaces" New topic
Author

Word wrapping long text without whitespaces

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 7602

I have a scenario where some text can be quite long, without white spaces. What is the recommended CSS way to make sure it wraps properly?


[Donate a pint, save a life!] [How to ask questions]
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 339

Did you try to put the text in a fixed width element and use the word-wrap property?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
If the browser supports CSS3, you have word-wrap, it not, you are basically out of luck. You can also look into zero width space character.

Eric
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 7602

Thanks for the suggestions guys.

@Eric
I did try the zero width space character and it works fine. Problem was I had to write some code snippet which would insert the character after every n characters. I was wondering if there was a "better" CSS approach.

For now I have used the word-wrap as well as the zero width space character.

 
 
subject: Word wrapping long text without whitespaces
 
Threads others viewed
converting int to long
Wrapping the output of a outputText embedded in a DataTable
Passed JCP with 93%
Form in Jsp
Apply Unicode escapes?
developer file tools