Support0

CSS field-sizing playground

Explore field-sizing with controls for switching between content and fixed, compare compatible form field sizing, and copy production-ready CSS.

Ask AI

CSS field-sizing playground

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.
HTML
<form class="field-sizing-demo">
  <label>
    Text
    <input type="text" value="BaselineLab" />
  </label>

  <label>
    Email
    <input type="email" value="dev@baseline.lab" />
  </label>

  <label>
    Number
    <input type="number" value="2026" />
  </label>

  <label>
    Password
    <input type="password" value="field-sizing" />
  </label>

  <label>
    Search
    <input type="search" value="CSS forms" />
  </label>

  <label>
    Tel
    <input type="tel" value="+34 600 000 000" />
  </label>

  <label>
    URL
    <input type="url" value="https://baselinelab.dev" />
  </label>

  <label>
    File
    <input type="file" />
  </label>

  <label>
    Select
    <select>
      <option>content</option>
      <option>fixed</option>
    </select>
  </label>

  <label>
    Textarea
    <textarea>field-sizing adapta el tamaño al contenido.</textarea>
  </label>
</form>
Tailwind CSS
Examples for Tailwind CSS 4.3 with the default theme. Custom values keep arbitrary classes when there is no equivalent utility. Changing the theme can change utility values.
<form class="flex flex-col items-start gap-3.5 max-inline-176 *:grid *:content-start *:gap-[0.35rem] [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:field-sizing-content [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:py-[0.62rem] [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:px-[0.78rem] [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:border [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:border-solid [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:border-[color-mix(in_srgb,_currentColor_24%,_transparent)] [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:rounded-lg [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url],select,textarea)]:[font:inherit] [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url])]:min-inline-[10ch] [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url])]:inline-auto [&_:where(input[type=email],input[type=file],input[type=number],input[type=password],input[type=search],input[type=tel],input[type=text],input[type=url])]:max-inline-full [&_textarea]:min-block-[3lh] [&_textarea]:max-inline-full [&_textarea]:resize-y">
  <label>
    Text
    <input type="text" value="BaselineLab" />
  </label>

  <label>
    Email
    <input type="email" value="dev@baseline.lab" />
  </label>

  <label>
    Number
    <input type="number" value="2026" />
  </label>

  <label>
    Password
    <input type="password" value="field-sizing" />
  </label>

  <label>
    Search
    <input type="search" value="CSS forms" />
  </label>

  <label>
    Tel
    <input type="tel" value="+34 600 000 000" />
  </label>

  <label>
    URL
    <input type="url" value="https://baselinelab.dev" />
  </label>

  <label>
    File
    <input type="file" />
  </label>

  <label>
    Select
    <select>
      <option>content</option>
      <option>fixed</option>
    </select>
  </label>

  <label>
    Textarea
    <textarea>field-sizing adapta el tamaño al contenido.</textarea>
  </label>
</form>
CSS
.field-sizing-demo {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 0.875rem;
  max-inline-size: 44rem;
}

.field-sizing-demo label {
  display: grid;
  align-content: start;
  gap: 0.35rem;
}

.field-sizing-demo :where(input[type="email"], input[type="file"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="url"], select, textarea) {
  field-sizing: content;
  padding-block: 0.62rem;
  padding-inline: 0.78rem;
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
  border-radius: 0.5rem;
  font: inherit;
}

.field-sizing-demo :where(input[type="email"], input[type="file"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="url"]) {
  min-inline-size: 10ch;
  inline-size: auto;
  max-inline-size: 100%;
}

.field-sizing-demo :where(textarea) {
  min-block-size: 3lh;
  max-inline-size: 100%;
  resize: vertical;
}

Educational guide to field-sizing

Fields that grow with content, within limits

Understand what field-sizing: content changes, how placeholders and layout interact, and how to keep fields usable with or without automatic sizing.

Mental model

The property changes the control’s preferred size. Available space, alignment, and CSS constraints still participate in the result.

  1. Content

    Text, a placeholder, or the selected option provides an intrinsic measurement.

  2. Constraints

    Minimums, maximums, and container space bound growth.

  3. Accessible content

    At the maximum size, the field keeps editing and internal scrolling available.

Content → constraints → used sizeStatic diagram. The examples below use editable native controls; their sizes can vary with the font and browser.

fixed is the initial value: it keeps the control’s usual preferred size, rather than an immutable pixel width. With content, that size is calculated from the content. The property is not inherited: apply it to the input, textarea, or select, rather than only its container.

content versus fixed

Let a short field take up less space without making it hard to locate when empty.

Use content for short values when variable width helps read the data. For forms with stable columns, fixed and an adaptive width may be a better choice. Field size does not limit value length or replace validation.

The same text, two sizing rules

Without field-sizing: content: conventional sizing and internal scrolling.

Enter the same short and long text in both fields. With support, content changes width between its minimum and the container; fixed keeps its CSS width. At the maximum, text remains editable through internal scrolling.
The same text, two sizing rules
<div class="field-scene-inputs">
  <label>
    Fit to content · content
    <input class="content" type="text" value="CSS" />
  </label>
  <label>
    Conventional reference · fixed
    <input class="fixed" type="text" value="CSS" />
  </label>
  <p class="fallback">Without field-sizing: content: conventional sizing and internal scrolling.</p>
</div>
:root {
  color-scheme: light dark;
}

.field-scene-inputs {

  display: grid;
  justify-items: start;
  gap: 1rem;
  min-inline-size: 0;

  label {
    display: grid;
    justify-items: start;
    gap: 0.5rem;
    inline-size: 100%;
    min-inline-size: 0;
    font-size: 1rem;
  }

  :is(input, textarea, select) {
    field-sizing: fixed;
    box-sizing: border-box;
    min-inline-size: 0;
    max-inline-size: 100%;
    min-block-size: 2.75rem;
    padding: 0.5rem;
    border: 1px solid light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    border-radius: 16px;
    corner-shape: squircle;
    background: light-dark(color-mix(in oklch, oklch(0.95 0.008 95) 94%, white), color-mix(in oklch, oklch(0.22 0.024 260) 92%, black));
    color: light-dark(oklch(0.22 0.01 95), oklch(0.95 0.01 95));
    font: inherit;
    line-height: 1.5;

    &:focus-visible {
      outline: 3px solid light-dark(oklch(0.46 0.14 261), oklch(0.82 0.18 261));
      outline-offset: 3px;
    }
  }

  input::placeholder {
    color: light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    opacity: 1;
  }

  .fallback {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
  }

  @media (forced-colors: active) {
    :is(input, textarea, select) {
      border-color: ButtonText;
      background: Canvas;
      color: CanvasText;

      &:focus-visible {
        outline-color: Highlight;
      }
    }
  }

  input {
    inline-size: min(100%, 24ch);
  }

  @supports (field-sizing: content) {
    .content {
      field-sizing: content;
      inline-size: auto;
      min-inline-size: min(10ch, 100%);
    }

    .fixed {
      field-sizing: fixed;
    }

    .fallback {
      display: none;
    }
  }
}

The recipe reuses the playground’s 10ch minimum. ch measures the width of the font’s “0” glyph, rather than any ten characters. min(10ch, 100%) lets that minimum shrink in narrow spaces; max-inline-size prevents content from widening the page.

Placeholder, minimums, and layout

An empty field can be as wide as its hint; once you type, that hint stops determining its size.

Keep a persistent label: a placeholder is a hint that disappears. With content, clearing the value can widen the field when a long placeholder returns. The input’s size attribute stops determining its preferred size; use CSS constraints to keep a comfortable minimum.

A long hint and a short value

Without field-sizing: content: conventional sizing and internal scrolling.

Type “CSS”, add text, and clear it again. With support, the empty hint and the value produce different widths, with an adaptive 10ch minimum and a maximum equal to the smaller of 32ch or the available space.
A long hint and a short value
<div class="field-scene-placeholder">
  <label>
    Project name
    <input type="text" placeholder="For example, my component library" />
  </label>
  <p class="fallback">Without field-sizing: content: conventional sizing and internal scrolling.</p>
</div>
:root {
  color-scheme: light dark;
}

.field-scene-placeholder {

  display: grid;
  justify-items: start;
  gap: 1rem;
  min-inline-size: 0;

  label {
    display: grid;
    justify-items: start;
    gap: 0.5rem;
    inline-size: 100%;
    min-inline-size: 0;
    font-size: 1rem;
  }

  :is(input, textarea, select) {
    field-sizing: fixed;
    box-sizing: border-box;
    min-inline-size: 0;
    max-inline-size: 100%;
    min-block-size: 2.75rem;
    padding: 0.5rem;
    border: 1px solid light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    border-radius: 16px;
    corner-shape: squircle;
    background: light-dark(color-mix(in oklch, oklch(0.95 0.008 95) 94%, white), color-mix(in oklch, oklch(0.22 0.024 260) 92%, black));
    color: light-dark(oklch(0.22 0.01 95), oklch(0.95 0.01 95));
    font: inherit;
    line-height: 1.5;

    &:focus-visible {
      outline: 3px solid light-dark(oklch(0.46 0.14 261), oklch(0.82 0.18 261));
      outline-offset: 3px;
    }
  }

  input::placeholder {
    color: light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    opacity: 1;
  }

  .fallback {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
  }

  @media (forced-colors: active) {
    :is(input, textarea, select) {
      border-color: ButtonText;
      background: Canvas;
      color: CanvasText;

      &:focus-visible {
        outline-color: Highlight;
      }
    }
  }

  input {
    inline-size: min(100%, 24ch);
  }

  @supports (field-sizing: content) {
    input {
      field-sizing: content;
      inline-size: auto;
      min-inline-size: min(10ch, 100%);
      max-inline-size: min(100%, 32ch);
    }

    .fallback {
      display: none;
    }
  }
}

If the field refuses to shrink, check inline-size: 100%, width, and Grid/Flex stretching. This scene uses inline-size: auto and justify-items: start to reveal intrinsic width. A minimum larger than the maximum can take precedence: adapt both to the actual space.

Textarea: stable width, adaptive height

Constrain the inline axis so text wraps and growth happens along the block axis.

In a multiline box, inline-size: 100% can be intentional: it fixes the available width while block-size: auto allows height to grow. min-block-size keeps a comfortable editing area and max-block-size prevents a long message from pushing the whole interface away.

A message that grows up to eight line heights

Without field-sizing: content: conventional sizing and internal scrolling.

Add lines or paste a paragraph. With support, the box grows up to 8lh and then allows internal scrolling. Clearing text brings it back toward its 3lh minimum. It also keeps manual vertical resizing available.
A message that grows up to eight line heights
<div class="field-scene-textarea">
  <label>
    Message
    <textarea rows="3">Describe the change you would like to propose here.</textarea>
  </label>
  <p class="fallback">Without field-sizing: content: conventional sizing and internal scrolling.</p>
</div>
:root {
  color-scheme: light dark;
}

.field-scene-textarea {

  display: grid;
  justify-items: start;
  gap: 1rem;
  min-inline-size: 0;

  label {
    display: grid;
    justify-items: start;
    gap: 0.5rem;
    inline-size: 100%;
    min-inline-size: 0;
    font-size: 1rem;
  }

  :is(input, textarea, select) {
    field-sizing: fixed;
    box-sizing: border-box;
    min-inline-size: 0;
    max-inline-size: 100%;
    min-block-size: 2.75rem;
    padding: 0.5rem;
    border: 1px solid light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    border-radius: 16px;
    corner-shape: squircle;
    background: light-dark(color-mix(in oklch, oklch(0.95 0.008 95) 94%, white), color-mix(in oklch, oklch(0.22 0.024 260) 92%, black));
    color: light-dark(oklch(0.22 0.01 95), oklch(0.95 0.01 95));
    font: inherit;
    line-height: 1.5;

    &:focus-visible {
      outline: 3px solid light-dark(oklch(0.46 0.14 261), oklch(0.82 0.18 261));
      outline-offset: 3px;
    }
  }

  input::placeholder {
    color: light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    opacity: 1;
  }

  .fallback {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
  }

  @media (forced-colors: active) {
    :is(input, textarea, select) {
      border-color: ButtonText;
      background: Canvas;
      color: CanvasText;

      &:focus-visible {
        outline-color: Highlight;
      }
    }
  }

  textarea {
    inline-size: 100%;
    block-size: auto;
    min-block-size: 3lh;
    max-block-size: 8lh;
    overflow: auto;
    resize: vertical;
  }

  @supports (field-sizing: content) {
    textarea {
      field-sizing: content;
    }

    .fallback {
      display: none;
    }
  }
}

rows and cols describe conventional preferred sizing and stop determining it with content. rows="3" remains useful in the unsupported base. lh depends on computed line height; with box-sizing: border-box, borders and padding are inside the limit, so 8lh does not promise eight fully visible lines.

Select and other controls

The measurement depends on the field type and the information it displays.

In a dropdown select, content sizes the button to the current option; conventional presentation usually accounts for the longest one. This does not enable base-select or customize the picker: size, appearance, and semantics are separate decisions.

The selected option determines width

Without field-sizing: content: conventional sizing and internal scrolling.

Switch between the short and long options with a keyboard or pointer. With support, the field changes width without exceeding its container. At 320 px the constraint can make both widths equal or clip option text: use understandable names and check every choice.
The selected option determines width
<div class="field-scene-select">
  <label>
    Report format
    <select>
      <option value="compact">Brief</option>
      <option value="extended">Summary with recommendations</option>
    </select>
  </label>
  <p class="fallback">Without field-sizing: content: conventional sizing and internal scrolling.</p>
</div>
:root {
  color-scheme: light dark;
}

.field-scene-select {

  display: grid;
  justify-items: start;
  gap: 1rem;
  min-inline-size: 0;

  label {
    display: grid;
    justify-items: start;
    gap: 0.5rem;
    inline-size: 100%;
    min-inline-size: 0;
    font-size: 1rem;
  }

  :is(input, textarea, select) {
    field-sizing: fixed;
    box-sizing: border-box;
    min-inline-size: 0;
    max-inline-size: 100%;
    min-block-size: 2.75rem;
    padding: 0.5rem;
    border: 1px solid light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    border-radius: 16px;
    corner-shape: squircle;
    background: light-dark(color-mix(in oklch, oklch(0.95 0.008 95) 94%, white), color-mix(in oklch, oklch(0.22 0.024 260) 92%, black));
    color: light-dark(oklch(0.22 0.01 95), oklch(0.95 0.01 95));
    font: inherit;
    line-height: 1.5;

    &:focus-visible {
      outline: 3px solid light-dark(oklch(0.46 0.14 261), oklch(0.82 0.18 261));
      outline-offset: 3px;
    }
  }

  input::placeholder {
    color: light-dark(oklch(0.38 0.008 95), oklch(0.78 0.018 260));
    opacity: 1;
  }

  .fallback {
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
  }

  @media (forced-colors: active) {
    :is(input, textarea, select) {
      border-color: ButtonText;
      background: Canvas;
      color: CanvasText;

      &:focus-visible {
        outline-color: Highlight;
      }
    }
  }

  select {
    inline-size: min(100%, 32ch);
  }

  @supports (field-sizing: content) {
    select {
      field-sizing: content;
      inline-size: auto;
      min-inline-size: min(10ch, 100%);
    }

    .fallback {
      display: none;
    }
  }
}

In multiple or size greater than 1 listboxes, content can expand the box to show the options; also limit its height when there are many. Text, email, number, password, search, tel, and url inputs can fit their content; file inputs use the filename. Do not expect every input type, such as checkbox or range, to grow with text.

Common mistakes

Inspect the axis, used size, and constraints before adding JavaScript synchronization.

The field does not change width

Expected result
A short value reduces the input’s width.
Cause
An explicit width, layout stretching, or a large minimum dominates the used size.
Solution
Free the axis that should grow with inline-size: auto and start alignment; review minimums and maximums. For textarea, you can keep the width and free only the height.

The empty field almost disappears

Expected result
An editing area is always visible and comfortable to use.
Cause
Without a value, placeholder, or minimum, the intrinsic size can approach that of the caret.
Solution
Add an adaptive min-inline-size and sufficient minimum height. Keep the label and test clearing all text, enlarged text, and narrow screens.

The message loses lines as it grows

Expected result
All content remains accessible at the maximum height.
Cause
A fixed height prevents growth or overflow: hidden hides excess content.
Solution
Use block-size: auto, block constraints, and overflow: auto; preserve focus and scrolling. Do not confuse visual size with maxlength.

The form jumps while typing

Expected result
Editing keeps a predictable layout.
Cause
A long placeholder and short value produce different measurements, or growth pushes neighboring actions.
Solution
Use a short hint, a sensible minimum, and stable space for actions. Keep an adaptive fixed width when continuous resizing adds no value; do not animate every keystroke.

Support and compatibility

Treat automatic sizing as progressive enhancement and keep a usable base.

field-sizing has been Baseline Newly Available since June 16, 2026. The consulted references record Chrome/Edge 123, Firefox 152, and Safari 26.2. Older versions may keep conventional sizing; the card describes availability across browsers, rather than an audit of every control.

@supports (field-sizing: content) queries acceptance of that declaration, rather than effective growth, keyboard behavior, or accessibility. Scenes show a notice when the enhancement is not applied and keep width, constraints, and scrolling. The fixed reference compares explicit rules in your engine; it does not simulate another browser.

These examples need no polyfill. Without support, inputs remain editable and the textarea uses conventional sizing and scrolling. Check labels, long options, focus, and navigation in your audience’s browsers and assistive technologies.