1

I have a paragraph tag inside a table, and for example it has a text like this...

4: asldkflaksdjflks, lasjdlfjsaldfjasldjfoajsdkfjaslkdjlkfasjdfwoidjfalk,zmncv,mznoqeworjoiejflaksdlfjwaf

How can the text wrap something like this..

4: asldkflaksdjflks, lasjdlfjsaldfjasldjfoajsdkfjaslkdjlkfasj
dfwoidjfalk,zmncv,mznoqeworjoiejflaksdlfjwaf

I have tried word-wrap:break-word; but it doesn't seem to work. I'm using IE8

Here is my css:

#notes table tr td p{
    font-family:Arial;
    padding:2% 2% 2% 5%;
    table-layout: fixed;
    word-wrap: break-word;

Update 1

I was wrong with my question. Sorry about that. I want the text not to wrap, even though there is a white-space. But it will go down to the next line if necessary. Hope that I'm clearer this time.

Is there a character that looks like a space, but doesn't serve as a breakpoint for the word wrap?

Josh Darnell
  • 11,304
  • 9
  • 38
  • 66
jovhenni19
  • 450
  • 2
  • 8
  • 24
  • possible duplicate of [How to word wrap text in HTML?](http://stackoverflow.com/questions/1147877/how-to-word-wrap-text-in-html) – Chris Oct 20 '11 at 09:00
  • `word-wrap:break-word` will only break the word if it is necessary; it gives it permission to break a word, but doesn't force it to. If normal word wrapping can be displayed without any overflows, then it'll use that in preference to breaking the word. – Spudley Oct 20 '11 at 09:02

3 Answers3

2

You could put your text into a <pre> tag, and put the <pre> tag in you <p> tag. A <pre> allows you to control text wrapping within the html. If the <p> collapses to the size of the <pre>, then set a width on the <p>. Does that help?

SamStar
  • 335
  • 2
  • 17
1

&nbsp; is an HTML non-breaking space. Is that what you're looking for?

0

As explained here : http://www.css3files.com/text/#wordwrap the word-wrap property is not compatible with IE8.

I think it's impossible to do this on IE8 with simple HTML and CSS, you will have to do it in javascript.

EDIT: It seems that there's finally a solution for that : word-wrap:break-word not working in IE8

Community
  • 1
  • 1
adriantoine
  • 2,160
  • 1
  • 15
  • 14