Connecting Tech Pros Worldwide Help | Site Map

How To Wrap Text With CSS

Newbie
 
Join Date: Mar 2007
Posts: 5
#1: Apr 4 '07
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9. <table width="777" border="0" cellspacing="0" cellpadding="0">
  10.   <tr>
  11.     <td>gdgdgdfgdf</td>
  12.     <td style="clear:right">gdfggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg</td>
  13.   </tr>
  14. </table>
  15. </body>
  16. </html>
  17.  
How can i able to arrange this text to wrap using css. Anyone help me pls
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#2: Apr 4 '07

re: How To Wrap Text With CSS


Trying using word-wrap: break-word
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#3: Apr 5 '07

re: How To Wrap Text With CSS


word-wrap? What's that?

You have to play with the width of table and the width of the rows and cells.
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#4: Apr 5 '07

re: How To Wrap Text With CSS


word-wrap

seems that only IE supports it, or it did when the above resource was written.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#5: Apr 5 '07

re: How To Wrap Text With CSS


Then it is worthless. Do not use it.
Newbie
 
Join Date: Mar 2007
Posts: 5
#6: Apr 5 '07

re: How To Wrap Text With CSS


Quote:

Originally Posted by KevinADC

word-wrap

seems that only IE supports it, or it did when the above resource was written.


Thanks for the suggestion. It works with <div> and <p> but if i use inside table word is not wrapping.

Any suggestions pls
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#7: Apr 5 '07

re: How To Wrap Text With CSS


it seems to work if you define the properties in the TD cell:

<td style="word-wrap: break-word" width="100">
Newbie
 
Join Date: Mar 2007
Posts: 5
#8: Apr 5 '07

re: How To Wrap Text With CSS


Quote:

Originally Posted by KevinADC

it seems to work if you define the properties in the TD cell:

<td style="word-wrap: break-word" width="100">

Thank you very much it works fine.
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#9: Apr 5 '07

re: How To Wrap Text With CSS


Again, a reminder, that word-wrap does nothing for any other browser.
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#10: Apr 5 '07

re: How To Wrap Text With CSS


Quote:

Originally Posted by drhowarddrfine

Again, a reminder, that word-wrap does nothing for any other browser.

Huh, I should have checked the compatible browsers sorry karthi.
Familiar Sight
 
Join Date: Sep 2006
Posts: 142
#11: Apr 19 '07

re: How To Wrap Text With CSS


Quote:

Originally Posted by KevinADC

it seems to work if you define the properties in the TD cell:

<td style="word-wrap: break-word" width="100">

Hi,

I am struggling with the same problem using Coldfusion 5 where I want to cut off the text and not allowing for text wrap in my column.

<td style="word-wrap: break-word" width="100" align="left">#test#<td>

I used the previous example but unfortunately it does not work.

Any help please!

Thank You
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#12: Apr 19 '07

re: How To Wrap Text With CSS


Change everything in style to style="width:100px"
Familiar Sight
 
Join Date: Sep 2006
Posts: 142
#13: Apr 20 '07

re: How To Wrap Text With CSS


Quote:

Originally Posted by drhowarddrfine

Change everything in style to style="width:100px"

Thank You it worked :-)
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#14: Apr 20 '07

re: How To Wrap Text With CSS


You don't want the text to wrap?

<td nowrap>text</td>

there might be a CSS equivalent to the nowrap attribute. Note that nowrap is a stand alone attribute, there is no "=value" part.
Newbie
 
Join Date: Apr 2007
Posts: 3
#15: Apr 23 '07

re: How To Wrap Text With CSS


Quote:

Originally Posted by KevinADC

You don't want the text to wrap?

<td nowrap>text</td>

there might be a CSS equivalent to the nowrap attribute. Note that nowrap is a stand alone attribute, there is no "=value" part.


According to w3.org "nowrap" is deprecated. You should be using <td style="white-space:nowrap;">Cell Contents</td> I've found this to work in both IE6 and FF 2.x without having to specify a column width.
Newbie
 
Join Date: Feb 2009
Posts: 1
#16: Feb 14 '09

re: How To Wrap Text With CSS


<td style="WORD-BREAK:BREAK-ALL;"> here is ur data </td>

let me know... :)
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#17: Feb 14 '09

re: How To Wrap Text With CSS


if you have long words you can also use the soft hyphen (&#173; or &shy;).
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,561
#18: Feb 14 '09

re: How To Wrap Text With CSS


Quote:

Originally Posted by navink View Post

<td style="WORD-BREAK:BREAK-ALL;"> here is ur data </td>

let me know... :)

Wonderful. Another non-existent solution with a non-existent property to a 2-year old thread.

Actually, that property now exists in CSS3 but it's not supported by any browser.
Reply