1

We have a number of large textareas on a page which all have fixed heights, for example:

<textarea id="qt_107" name="qt_107" style="width:695px;height:150px;" maxlength="8000" question="107" class="">

I am working on the print version of the css for this page, and we would like the heights of the textareas to change to display all of the text within the textarea.

I have looked online for a solution, but only came across JQuery / Javascript methods, which would apply to the webpage on all media types, not just print.

I also tried height:auto!important; but this doesn't work.

Thanks

Edit: I understand this is not possible without javascript, Is it possible to only run the javascript on the print view, and not on the screen?

user2924019
  • 1,581
  • 3
  • 24
  • 44
  • 3
    You can not without JavaScript. But JavaScript is not eval, just use it – CoderPi Jan 06 '16 at 10:55
  • @Eria Thanks, didn't see that post before. My issue is slightly different in that I don't want to use javascript on the screen view, only on the print view. – user2924019 Jan 06 '16 at 11:01
  • That answer that @Eria linked doesn't use any JS. Also regarding the JS-on-the-print-view: print view is a piece of paper. How would you run code there? ;) – N3dst4 Jan 06 '16 at 11:39

1 Answers1

2

You can use contentEditable like so: https://jsfiddle.net/Lyoa6enn/

But you can't set a maximum length for the content of the div without using JS.

fnune
  • 4,685
  • 1
  • 20
  • 34