CSS Reference Property

resize u7067

The resize property allows you to specify whether or not an element is resizable by the , and if so, along which direction. 1s4t1

Currently it is possible to control the appearance of the scrolling mechanism (if any) on an element using the overflow property (e.g. overflow: scroll vs. overflow: hidden etc.). The purpose of the resize property is to also allow control over the appearance and function of the resizing mechanism (e.g. a resize box or widget) on the element.

When an element is resizable, the agent presents the with a resizing mechanism, which is usually a small triangular “knob” at the bottom right corner of the element, similar to the one you see on textareas. This knob can be dragged by the to expand the textarea in either direction — horizontally or vertically, or both.

resize-mechanism
The resizable textarea has a small triangular “knob” at its corner that indicates that it is resizable. This knob can be dragged by the to expand the textarea in two directions — vertically and horizontally.

You can make an element resizable in both directions or either horizontally or vertically.

When an element is resizable, the can increase its size by cannot make it smaller than it is. However, some browsers such as Firefox will let the resize an element to a size that’s smaller than its default size.

You can make any block-level and replaced element, table cell, and inline block element resizable using resize. However, resize will have no effect on the element unless the value of the overflow-y), then this property applies to the dimension(s) which do not have the value visible.

The resize property is also used to prevent certain interface elements that are resizable by default from being resized, especially textareas. Sometimes allowing the to resize an element may affect the entire layout around that element in an undesirable way, so it is sometimes preferable to either prevent the element from being resized, or restrict its resizability to one direction only, depending on the layout.

The resizing mechanism is NOT the same as the scrolling mechanism. The scrolling mechanism allows the to determine which portion of the contents of an element is shown. The resizing mechanism allows the to determine the size of the element.

Official Syntax 3xs5l

  • Syntax:

    resize: none | both | horizontal | vertical | inherit 
  • Initial: none
  • Applies To: elements with overflow other than visible
  • Animatable: no

Values u704t

none
The element is not resizable. The agent does not present a resizing mechanism on the element, and the is given no direct manipulation mechanism to resize the element.
both
The element is resizable in both directions (horizontal and vertical). The agent presents a bidirectional resizing mechanism to allow the to adjust both the height and the width of the element.
horizontal
The element can be resized horizontally. The agent presents a unidirectional horizontal resizing mechanism to allow the to adjust only the width of the element.
vertical
The element can be resized vertically. The agent presents a unidirectional vertical resizing mechanism to allow the to adjust only the height of the element.
inherit
The element inherits its resize value from its parent.

Examples 2h2053

The following disables the resizability of a textarea:

textarea#comments {
    resize: none;
}
                

The following example makes a div resizable only vertically. That is, the can increase its height (or decrease it in Firefox):

div.resizable {
    resize: vertical;
}
                

Browser 572e63

CSS resize property 6a4zh

Method of allowing an element to be resized by the , with options to limit to a given direction.

W3C Candidate Recommendation

ed from the following versions:

Desktop ea5q

  • 4
  • 5
  • No
  • 15
  • 4

Mobile / Tablet 6s2f12

  • No
  • 66
  • No
  • 66
  • 60

* denotes prefix required.

  • ed:
  • Yes
  • No
  • Partially
  • Polyfill

Stats from caniuse.com

Further Reading 4s104w

Written by

Last updated June 11, 2020 at 10:45 pm by Mary Lou

Do you have a suggestion, question or want to contribute? Submit an issue.