12 Replies - 77229 Views - Last Post: 16 December 2010 - 06:03 AM

#1 DanceInstructor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-March 05

Force Long Strings to Wrap

Posted 15 April 2005 - 01:50 PM

f I have a long string of text in say a table cell, how can I make it break so it doesn't cause horizontal scrolling? Thanks :)
Is This A Good Question/Topic? 0
  • +

Replies To: Force Long Strings to Wrap

#2 FernFerret  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 14-April 05

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 02:14 PM

add
<br>


example:

<P>I like Fish. I like them a lot.</P>

Result:
I like fish. I like them a lot.
<P>I like fish. <br>I like them a lot.</P>

Result:
I like fish.
I like them a lot.

This post has been edited by FernFerret: 15 April 2005 - 02:17 PM

Was This Post Helpful? 0
  • +
  • -

#3 DanceInstructor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-March 05

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 02:18 PM

Yes that would work :) but I want it to break wherever it needs to depending on the users browser, screen size, and text dispaly settings. I hope that makes sense. BTW I mean a string of text like so:

0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789

This post has been edited by DanceInstructor: 15 April 2005 - 02:20 PM

Was This Post Helpful? 0
  • +
  • -

#4 FernFerret  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 14-April 05

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 02:24 PM

Sorry I assumed u knew <br> but u never kno ;)
I bet that would be easier in php, I kno a little, but not much.
Was This Post Helpful? 0
  • +
  • -

#5 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 02:53 PM

IIRC there is some CSS thing you can do. Though at this time I cannot remember what it is.
Was This Post Helpful? 0
  • +
  • -

#6 DanceInstructor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-March 05

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 03:06 PM

uhh... Thanks hotsnoj :P
Was This Post Helpful? 0
  • +
  • -

#7 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1875
  • View blog
  • Posts: 20,284
  • Joined: 17-March 01

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 03:33 PM

There is CSS, however, it is only supported in IE... and there is another tag... <wbr> that has been supported on and off in various browsers...

For the low down on forcing word wrapping on long string, check out this page.
Was This Post Helpful? 0
  • +
  • -

#8 DanceInstructor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-March 05

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 03:49 PM

http://www.cs.tut.fi/~jkorpela/html/nobr.html said:

but it is best to avoid long strings that contain no spaces.


:(
Pretty much the same response I got at DaniWeb.

Thanks everyone for replying.
Was This Post Helpful? 0
  • +
  • -

#9 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 04:27 PM

How are you getting the data for that cell? If it's coming from a database, you can wrap it as you print it. PHP has a built in word wrap
wordwrap($texttowrap, 40, "<br/>", 1);
//the 40 represents the number of characters max


You can also write a word wrap function in any scripting language.
Was This Post Helpful? 1

#10 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,411
  • Joined: 21-March 01

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 05:01 PM

i thought it was possible to make a cell not expand width wise no matter what was in it?
Was This Post Helpful? 0
  • +
  • -

#11 DanceInstructor  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 18-March 05

Re: Force Long Strings to Wrap

Posted 15 April 2005 - 08:27 PM

supersloth said:

i thought it was possible to make a cell not expand width wise no matter what was in it?


You would think that if you specify the width, then it would be that width no matter what....

Here is some code that I was playing with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/> <title>Variables</title>
<style>
.var_name { width: 250px; overflow: hidden; }
.var_value { width: 500px; overflow: hidden; }
table { width: 750px; }
</style>
</head>
<body>
<table border="1" >
<tr>
 <td class="var_name">stuff</td>
 <td class="var_value">01234567891123456789212345678931234567894123456789512345678912345678971234567898123456789912345678901234567891123456789212345678931234567898</td> </tr>
</table>
</body>
</html>


Yes I will deal with it in php, but why should I have to lol? Just seems like there should be a css/html way to deal with something like this.

Thanks everyone B)
Was This Post Helpful? 0
  • +
  • -

#12 Guest_James*


Reputation:

Re: Force Long Strings to Wrap

Posted 18 October 2010 - 01:08 PM

I know this was posted in 2005, but if anyone comes here looking for an answer, as I did, here is what you can do Inside the table

Set the CSS property table-layout to fixed (this might have not been supported in 2005 I dont know). The cell width is now controlled by the specified width rather than the content inside. If you have long string you will need to use overflow: hidden, to stop the text from coming over into other cells.

In CSS3 you can use text-overflow: ellipsis which makes the 3 dots '...' if the text is too long. But this is not fully supported yet

Thanks
Was This Post Helpful? 0

#13 Guest_RWAP Services*


Reputation:

Re: Force Long Strings to Wrap

Posted 16 December 2010 - 06:03 AM

If anyone is still looking for an answer to this - try adding the css style:
word-wrap: break-word;

It seems to work in most modern browsers, but not sure it will be supported on all!
Was This Post Helpful? 0

Page 1 of 1