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..
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>
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; }
How about using the word-wrap property from CSS3? Maybe you could do something like this
h3 { word-wrap: break-word; }