CSS Resize Generator

Make a box or textarea resizable by the user, set limits, drag the live preview, and copy the CSS.

Drag the bottom-right corner of this box.

How the CSS resize property works

resize lets visitors drag the bottom-right corner of an element to change its size. It takes both, horizontal, vertical or none, plus the logical values block and inline, which follow the writing direction. Pick a value, set limits, and drag the preview to feel the result before copying the CSS.

One rule trips people up: resize only works when overflow is something other than visible. That is why the generated CSS adds overflow: auto to boxes. Textareas are already scrollable, so they do not need it.

Common recipes

GoalCSS
Stop users breaking a form layout by widening a textareatextarea { resize: vertical; }
Disable resizing completelytextarea { resize: none; } (give it a sensible height, or auto-grow it with field-sizing: content in browsers that support it)
Resizable side panelresize: horizontal; overflow: auto; min-width: 200px; max-width: 50vw;
Resizable code or preview paneresize: both; overflow: auto; with min and max sizes

Limits matter

min-width, max-width, min-height and max-height stop users from shrinking an element to nothing or stretching it over the rest of the page. Without a max-width, a horizontally resizable element can push past its container and cause horizontal scrolling on mobile.

Accessibility

The resize handle can only be used with a pointer, so do not make resizing the only way to see content: keep content scrollable inside the element. Browsers do not show the handle on most touch devices.

FAQ

Why doesn't resize work on my div?

Its overflow is visible (the default) or it is an inline element. Add overflow: auto and make sure it is a block or inline-block element.

Can I detect when an element is resized?

Yes, with a ResizeObserver in JavaScript, which is what the size readout under the preview uses.