36

Possible Duplicate:
wrapping the text inside div - css

Fiddle: http://jsfiddle.net/aTFK2/2/

HTML:

<div id="ChannelDescription">ThisIsAVeryLongTextWithoutAnySpacesLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmedLoremIpsumDolorSitAmed</div>​

CSS:

#ChannelDescription {
  width:560px;
  color:Gray;
  white-space:normal;
  font-size:14px;
}​

NOTE: I cannot change the width to any other value. Neither can I use break points. I am looking for a pure CSS2 solution.

3

1 Answer 1

73

word-wrap: break-word; will solve the problem.

5
  • word-break: break-word;
    – Tobias
    May 14, 2019 at 8:34
  • 31
    white-space: pre-wrap;
    – Renil Babu
    Jan 19, 2020 at 7:02
  • This will not work if width is 100%
    – sanjaymith
    Aug 27, 2020 at 5:15
  • 3
    @RenilBabu : Thanks , "white-space: pre-wrap;" worked for me.
    – Vineesh TP
    Sep 2, 2020 at 8:05
  • also don't forget to remove display: flex; from text div
    – help
    Feb 25, 2022 at 9:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.