• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Word wrapping long text without whitespaces

 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Koen Aerts
Ranch Hand
Posts: 344
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try to put the text in a fixed width element and use the word-wrap property?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic