Notice how it disappears when you start typing into the box.Get the latest and greatest from MDN delivered straight to your inbox.The newsletter is offered in English only at the moment. The idea. Hi there, I am making an app that require a textarea that is pretty height (almost the height of the view). While using this site, you agree to have read and accepted our The Element.scrollHeight read-only property is a measurement of the height of an element's content, including content not visible on the screen due to overflow.. The scrollHeight value is equal to the minimum height the element would require in order to fit all the content in the viewport without using a vertical scrollbar. I assume you want to fit it into the text area without wrapping (with wrapping, this is a different problem, also solvable, but this is not what you are asking about, because it would take width on input and produce required height on output, so we need to assume no-wrapping solution).
A protip by moak about jquery, ux, userexperience, textarea, and html.
The height of the textarea will either grow or shrink to fit the content (grow to a maximum of max-rows or shrink to a minimum of rows).. To set the initial minimum height (in rows), set the rows prop to the desired number of lines (or … element.scrollHeight gives us the height of the content, regardless of visible scrollbars.
Why painful? But unfortunately there is no auto-height property.
Also see the