-1

I want to scale a textarea based on its content, for example:

textarea {
  height: auto;
}
<textarea>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi illum obcaecati alias, quaerat enim eos esse corrupti ducimus eius saepe, odio dignissimos nihil dicta sunt cum voluptas quae magni reiciendis labore velit aliquid asperiores iure? Non laboriosam eaque quis voluptatibus recusandae doloribus, suscipit, at dignissimos, dicta voluptates corporis nisi! Voluptatem?
</textarea>

Hopefully you can find a solution

Emiel Van de Veire
  • 117
  • 1
  • 1
  • 8

1 Answers1

0

Unfortunately, there is no great way to do it with raw HTML or CSS, JavaScript is typically the solution especially with using the textarea element. However, you can use the contentEditable feature on a div, which will make it so the textbox automatically resizes based on content.

div {
  outline: solid 1px;
  width: 120px;
}
<div contentEditable></div>
Kameron
  • 10,240
  • 4
  • 13
  • 26