views:

67

answers:

3

I have a page that displays text the user typed in a form before that. If the user types a lot in the form and submits, the page that displays the text has a horizontal scroll bar. How could I make the text automatically do a line break after the text fills the screen? It needs to be 8.5 x 11 so it will print. What should I do to the textbox/display page? Here's some code I used:
text area:

<textarea name="body" id="textarea">

display page:

  <h3>
    <?php echo "$body"; ?> <br />
    </h3>

When the text is sent using post and get, it is encoded and decoeded. Thanks..

+1  A: 

You can use wordwrap() to get it done on the PHP side.

But you could just use a div with a predefined width:

<h3 style="width: 8.4in;">
    <?php echo "$body"; ?> <br />
</h3>
NullUserException
thanks for the reply, didn't work... ):
Preston
It is not working - What do you see? Try to set a background-color that stands out, it is easier to validate, and make sure and make sure that your display style is set block (or other block type).
Michael
A: 

The best thing you could do here is to set a width on your <h3> element. Since you need it to fit within 8.5x11", a width of 8.5" should be appropriate:

h3 { width: 8.5in; }
You
Thanks for the reply also, but I already tried that and it didn't work.
Preston
@Preston: Didn't work, how? What didn't work?
You
The text is still a long string of characters that go across the page without line breaking. Sorry that I wasn't clear enough.
Preston
A: 

How about using the word-wrap property from CSS3? Maybe you could do something like this

h3 { word-wrap: break-word; }
aidilfbk