The auto-growing textarea is one of the most copied scripts in frontend work. On every input event, set the height to auto, read scrollHeight, then write that value back as the new height. Variations add a hidden mirror element, a ResizeObserver, or a wrapper with a data- attribute that duplicates the text into a CSS grid trick. All of them exist because a form control would not size itself to what was typed into it.

The field-sizing property removes the need. web.dev’s June 2026 platform roundup reports that Firefox 152 added support, making the property Baseline Newly available with Chrome and Edge 123 and Safari 26.2 already shipping it.

The Two Values

The property takes two values:

  • fixed is the initial value. The control keeps the default sizing it has always had, driven by attributes such as size, rows, and cols.
  • content sizes the control to its content, so it shrinks or grows as the value changes.
textarea,
input[type="text"] {
  field-sizing: content;
}

According to MDN, the property applies to text input types such as text, email, search, tel, url, number, and password, to file inputs, to textarea, and to select in both its dropdown and listbox forms. That breadth is the reason it replaces more than one script.

Setting Sensible Bounds

Left unbounded, a control with field-sizing: content will be exactly as wide as its text cursor when empty, and a long paragraph will stretch it indefinitely. MDN recommends pairing the property with min-width, max-width, and for textareas, min-height and max-height.

textarea {
  field-sizing: content;
  min-height: 3lh;
  max-height: 12lh;
  width: 100%;
}

The lh unit equals the element’s computed line height, so these bounds read as “three to twelve lines”. When content exceeds the maximum, the control stops growing and scrolls internally, which preserves the layout around it.

A fixed width or height reimposes a size and defeats the shrink-wrap behavior for that axis. In the example above width: 100% is deliberate: the textarea fills its column and grows only vertically. If you want growth on both axes, set min-width and max-width instead and leave width alone.

How Textareas Grow

MDN describes the order of growth for a textarea. It expands in the inline direction first, up to whatever limit applies, then adds rows, and finally shows a scrollbar when the block size is capped. In a layout where the textarea fills its container width, the practical effect is the familiar one: it gets taller as the writer adds lines.

The rows and cols attributes have no effect once field-sizing: content is applied, and neither does size on an input. Remove them from your thinking, not necessarily your markup, since they remain a sensible default for browsers that do not support the property.

Inputs and Placeholders

Single-line inputs behave in two ways worth testing:

  • With no placeholder, an empty input collapses to roughly the width of the caret unless you set a min-width. A narrow, unlabeled sliver is a usability problem, so always set a minimum.
  • With a placeholder, the control sizes large enough to display it. On focus, MDN notes it adjusts to the minimum width, which can cause a visible jump in some layouts.

Inline-editable names, tag inputs, and search boxes that expand as the user types are the natural fits. Keep the label visible and associated with the control, because a narrow field gives less visual context than a full-width one.

Selects

For a dropdown select, field-sizing: content makes the width follow the currently displayed option instead of the longest option, which is the default behavior. That can be handy in toolbars where a short choice should not reserve space for a long one. It also means the control’s width changes when the user picks a different option, so check that neighbors do not reflow awkwardly. For listbox selects, MDN says all options display without scrolling instead of requiring a scroll.

Progressive Enhancement

Because Firefox 152 is the most recent engine to join, some visitors will have a browser without support for a while. The failure mode is gentle: an unsupported browser ignores the declaration and shows the fixed-size control. That makes this a good candidate for plain progressive enhancement. Write the control with a sensible rows value, add field-sizing: content, and do not remove the old script until your analytics show the older browsers are gone.

If you need to keep the script for now, wrap it in a feature check so supporting browsers skip it:

@supports (field-sizing: content) {
  textarea {
    field-sizing: content;
    max-height: 12lh;
  }
}

In script, CSS.supports("field-sizing", "content") returns the same answer, so the JavaScript fallback can exit early when the browser handles the sizing natively.

Things It Does Not Do

The property does not enforce a character limit. The maxlength attribute continues to cap how much can be typed, so a control will grow only as far as the permitted content allows. It also does not set a ceiling by itself, which is why the max-height and max-width bounds above matter.

Testing Before You Remove the Script

Before deleting an existing resize script, test the cases it quietly handled: pasting a long block of text, deleting everything, loading a form with a prefilled value, and restoring a draft after a page reload. A control with field-sizing: content sizes itself from whatever value it holds, so prefilled content should render at the right height on first paint, which scripts often got wrong until they ran. Also check zoom levels and larger default font sizes, since lh bounds scale with the text.

Practical Takeaway

Add field-sizing: content to the textareas and text inputs that currently use a resize script, pair it with min-height, max-height, and min-width bounds expressed in lh or ch, and wrap it in @supports while older browsers remain in your audience. Delete the scrollHeight handler once your support data allows. The result is less code to maintain and a control that responds to its content the way users already expect.