2

Let's suppose I have a textarea. I would like to resize the height of the textarea automatically each time its value/text is changed. It can be done with Javascript, but I am interested to know whether there is a pure HTML/CSS solution.

Lajos Arpad
  • 45,912
  • 26
  • 82
  • 148

1 Answers1

1

This cannot be done using pure CSS at least for <textarea>, the reason being, interaction can be captured only by JavaScript. But you can make something like <div> having a contenteditable, a fake <textarea> can be made possible.

Snippet

div {
  display:inline-block;
  border: solid 1px #999;
  min-height: 100px;
  width: 300px;
}
<div contentEditable></div>
Praveen Kumar Purushothaman
  • 154,660
  • 22
  • 177
  • 226