javascriptprintingtextareaprinting-web-page

Printing only a textarea


I would like to print only the contents of a textarea element from a website page. In particular, I would like to ensure that nothing gets clipped by the boundary of the textarea as the contents will be quite large.

What is the best strategy for tackling this?


Solution

  • Make a print stylesheet where all of the elements except the textarea are set in CSS to display: none;, and for the textarea, overflow: visible.

    Link it to the page with the link tag in the header set to media="print".

    You're done.