resize
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The resize
CSS property sets whether an element is resizable, and if so, in which directions.
Try it
resize
does not apply to the following:
- Inline elements
- Block elements for which the
overflow
property is set tovisible
Syntax
/* Keyword values */
resize: none;
resize: both;
resize: horizontal;
resize: vertical;
resize: block;
resize: inline;
/* Global values */
resize: inherit;
resize: initial;
resize: revert;
resize: revert-layer;
resize: unset;
The resize
property is specified as a single keyword value from the list below.
Values
none
-
The element offers no user-controllable method for resizing it.
both
-
The element displays a mechanism for allowing the user to resize it, which may be resized both horizontally and vertically.
horizontal
-
The element displays a mechanism for allowing the user to resize it in the horizontal direction.
vertical
-
The element displays a mechanism for allowing the user to resize it in the vertical direction.
block
-
The element displays a mechanism for allowing the user to resize it in the block direction (either horizontally or vertically, depending on the
writing-mode
anddirection
value). inline
-
The element displays a mechanism for allowing the user to resize it in the inline direction (either horizontally or vertically, depending on the
writing-mode
anddirection
value).
Formal definition
Initial value | none |
---|---|
Applies to | elements with overflow other than visible , and optionally replaced elements representing images or videos, and iframes |
Inherited | no |
Computed value | as specified |
Animation type | discrete |
Formal syntax
Examples
Disabling resizability of textareas
In many browsers, <textarea>
elements are resizable by default. You may override this behavior with the resize
property.
HTML
<textarea>Type some text here.</textarea>
CSS
textarea {
resize: none; /* Disables resizability */
}
Result
Using resize with arbitrary elements
You can use the resize
property to make any element resizable. In the example below, a resizable <div>
contains a resizable paragraph (<p>
element).
HTML
<div class="resizable">
<p class="resizable">
This paragraph is resizable in all directions, because the CSS `resize`
property is set to `both` on this element.
</p>
</div>
CSS
.resizable {
resize: both;
overflow: scroll;
border: 1px solid black;
}
div {
height: 300px;
width: 300px;
}
p {
height: 200px;
width: 200px;
}
Result
Specifications
Specification |
---|
CSS Basic User Interface Module Level 4 # resize |
Browser compatibility
BCD tables only load in the browser