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.
.panel { overflow: auto; resize: both; }
Try it
Syntax
resize: none | both | horizontal | vertical | block | inline
- Initial value:
none(but the default style sheet of browsers setsbothon<textarea>) - Applies to: elements with
overflowother thanvisible, 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
overflowis required. On a box with the defaultoverflow: visible,resizedoes nothing. Useoverflow: auto,hiddenorscroll.- The user's drag sets inline
widthandheight. Browsers apply the new size directly to the element, which overrides your style sheet values for that dimension. Setmin-*andmax-*sizes to keep the result sensible; they are respected while dragging. - Textareas.
resize: verticalis the best default for forms: users can make a comment field taller, but the width stays inside your layout. Usenoneonly when the design really cannot tolerate a size change. - Not for inline elements. A plain
<span>or other inline box has no handle. Make itdisplay: inline-blockorblockfirst. - 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.
Related
overflowโ required for the handle to appearmin-widthandmax-widthโ limit the resize rangefield-sizingโ sizes form controls to their contentcursorโ sets the mouse cursor- Lessons: User Interface, Overflow