This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
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: 10268
    
    8

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?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Koen Aerts
Ranch Hand

Joined: Feb 07, 2012
Posts: 344

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: 15376
    
    6
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: 10268
    
    8

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