Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

print all text in a textarea

including text below the scrollbar


Purple Martin

3:50 am on Oct 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

I want to print a textarea with all the text in it... including the text that has scrolled off the bottom of the area. By default, browsers just truncate the text at the end of the visible area and don't print any text that you'd need to scroll to see. Is there a CSS trick to this?


4:03 am on Oct 3, 2006 (gmt 0)

10+ Year Member

I've already tried this - using combinations of methods for setting 100% height, or visible overflow, minimum height, that sort of thing.

I couldn't get anything to work.

So I'm also interested to see if someone found a solution that's cross-browser compatible, or there isn't one.


5:23 am on Oct 3, 2006 (gmt 0)

5+ Year Member

Is it necessary to have the text in a textarea input element? If you're just displaying something like a TOS in a scrollable box, why don't you try this instead of a textarea:

<div style="width:500px;height:500px;overflow:auto;border:1px #000 solid;">
All the text here...

It'll look almost like your textarea, but it can easily print by changing the CSS. I've used inline styles, but you'd want to use an external stylesheet.

Purple Martin

12:17 am on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Nice idea foobar. Unfortunately it is necessary to have a textarea form element, because it is a data input form with a couple of fields which take a large amount of text with line breaks (e.g. a project description).


12:54 am on Oct 4, 2006 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

If you can't print the entire <textarea> directly then, using JavaScript, you might be able to copy it's contents into a DIV (perhaps in another window) and print that. Kind of how foobar suggested. To preserve line-breaks, you could try using
(although not very well supported!) or manually replace every new-line with a <br> ...?

Featured Threads

Hot Threads This Week

Hot Threads This Month