Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Scrolling, Interaction and UI

The resize property

Reference for the CSS resize property: add a drag handle to boxes and textareas, limit it to one direction, and combine it with overflow, min and max sizes.

The resize property adds a small drag handle to the bottom corner of an element so the user can change its size with the mouse or a pen. Browsers already do this for <textarea>; with resize you can turn it off, limit it to one direction, or add it to ordinary boxes.

It only works on elements whose overflow is something other than visible, because resizing makes sense only when content can be clipped or scrolled.

CSS
.panel {
  overflow: auto;
  resize: both;
}

Try it

Resizable boxes and textareas

Syntax

CSS
resize: none | both | horizontal | vertical | block | inline
  • Initial value: none (but the default style sheet of browsers sets both on <textarea>)
  • Applies to: elements with overflow other than visible, and optionally replaced elements such as <textarea>
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
none No handle; the user cannot resize the element.
both The user can change both width and height.
horizontal Only the width can be changed.
vertical Only the height can be changed.
inline Resizable along the inline axis (width in horizontal writing). Logical version of horizontal.
block Resizable along the block axis (height in horizontal writing). Logical version of vertical.

Usage notes

  • overflow is required. On a box with the default overflow: visible, resize does nothing. Use overflow: auto, hidden or scroll.
  • The user's drag sets inline width and height. Browsers apply the new size directly to the element, which overrides your style sheet values for that dimension. Set min-* and max-* sizes to keep the result sensible; they are respected while dragging.
  • Textareas. resize: vertical is the best default for forms: users can make a comment field taller, but the width stays inside your layout. Use none only when the design really cannot tolerate a size change.
  • Not for inline elements. A plain <span> or other inline box has no handle. Make it display: inline-block or block first.
  • Touch devices. Many mobile browsers do not show the handle at all or make it hard to grab, so never make resizing the only way to see content.
  • Accessibility. The handle is a pointer feature; there is no standard keyboard way to resize. Make sure content stays readable at its default size.
  • Layout shifts. Resizing can push following content around. Reserve space or place the resizable element where that is acceptable.

Browser support

Supported in current versions of all major browsers; the logical values block and inline are newer than the physical ones, so check a compatibility table if you need old browsers.