CSS resize Property

The CSS resize property controls whether users can manually change an element's dimensions by dragging a resize handle.

It supports horizontal, vertical, and two-directional resizing, as well as logical directions based on writing mode. The property is commonly used with textareas, editable panels, and other elements that benefit from user-controlled dimensions.

resize Syntax

The resize property accepts keywords that specify which dimensions users may change.

Basic Syntax

selector {
  resize: both;
}

Available Values

.panel {
  resize: none;
}
.panel {
  resize: both;
}
.panel {
  resize: horizontal;
}
.panel {
  resize: vertical;
}
.panel {
  resize: block;
}
.panel {
  resize: inline;
}

CSS-Wide Keywords

.panel {
  resize: initial;
}
.panel {
  resize: inherit;
}
.panel {
  resize: unset;
}
.panel {
  resize: revert;
}
.panel {
  resize: revert-layer;
}

For ordinary elements, resizing generally requires an overflow value other than visible or clip.

Property Values

Value Description
none Disables user-controlled resizing. This is the initial value.
both Allows users to resize the element horizontally and vertically.
horizontal Allows users to change the element's width.
vertical Allows users to change the element's height.
block Allows resizing along the logical block axis, which depends on the writing mode.
inline Allows resizing along the logical inline axis, which depends on the writing mode.
initial Resets the property to none.
inherit Uses the computed value from the parent element.
unset Resets the property to none because it is not inherited.
revert Reverts the property according to CSS cascade origin rules.
revert-layer Reverts the property according to CSS cascade layer rules.

Property Characteristics

Characteristic Value
Initial value none
Inherited No
Applies to Elements with applicable overflow behavior, with special handling for certain form controls
Computed value As specified
Animation type Discrete
Percentages Not applicable

Valid Values

.editor {
  resize: both;
}
.sidebar {
  resize: horizontal;
}
.notes {
  resize: vertical;
}
.logical-panel {
  resize: inline;
}

Invalid Values

.panel {
  resize: auto;
}
.panel {
  resize: 200px;
}
.panel {
  resize: width;
}
.panel {
  resize: horizontal vertical;
}
.panel {
  resize: yes;
}

The property accepts one supported resizing keyword or a CSS-wide keyword. It does not accept lengths or multiple direction keywords.

How It Works

When resizing is enabled, a supporting browser provides a resize control, typically near a corner or edge of the element.

Users can drag this control to change the element's dimensions within any applicable CSS size constraints.

Step 1: Define the Element's Dimensions

.resizable-panel {
  width: 250px;
  height: 140px;
}

Step 2: Configure Overflow

.resizable-panel {
  overflow: auto;
}

This allows the panel to display scrollbars when its content exceeds the available dimensions.

Step 3: Enable Resizing

.resizable-panel {
  resize: both;
}

Complete Example

.resizable-panel {
  width: 250px;
  height: 140px;
  overflow: auto;
  resize: both;
  padding: 15px;
  border: 2px solid #64748b;
  background-color: #f8fafc;
}

The user can drag the resize handle to change the panel's width and height.

Important Distinction

The resize property enables manual resizing. It does not automatically adjust dimensions in response to content or viewport changes.

Resizing Directions

The resize property supports physical and logical resizing directions.

Horizontal Resizing

.horizontal-panel {
  width: 220px;
  height: 100px;
  overflow: auto;
  resize: horizontal;
}

Users can change the panel's width while its height remains controlled by the other CSS sizing rules.

Vertical Resizing

.vertical-panel {
  width: 220px;
  height: 100px;
  overflow: auto;
  resize: vertical;
}

Users can change the panel's height without manually changing its width.

Resizing in Both Directions

.flexible-panel {
  width: 220px;
  height: 100px;
  overflow: auto;
  resize: both;
}

Users can adjust both dimensions.

Logical Block Resizing

.block-panel {
  overflow: auto;
  resize: block;
}

The block value follows the logical block axis. In a horizontal writing mode, this generally corresponds to vertical resizing.

Logical Inline Resizing

.inline-panel {
  overflow: auto;
  resize: inline;
}

The inline value follows the logical inline axis. In a horizontal writing mode, this generally corresponds to horizontal resizing.

Physical Versus Logical Directions

Value Horizontal Writing Mode Vertical Writing Mode
horizontal Width Width
vertical Height Height
block Height Width
inline Width Height

Use logical values when the resizing direction should adapt to different writing modes.

Overflow Requirements

For ordinary elements, the resize property generally works only when the computed overflow value is neither visible nor clip.

Using overflow: auto

.panel {
  width: 250px;
  height: 120px;
  overflow: auto;
  resize: both;
}

Scrollbars appear when needed, and the element can be resized.

Using overflow: hidden

.panel {
  width: 250px;
  height: 120px;
  overflow: hidden;
  resize: both;
}

Resizing can remain available, but overflowing content is clipped rather than displayed with ordinary scrollbars.

Using overflow: scroll

.panel {
  width: 250px;
  height: 120px;
  overflow: scroll;
  resize: both;
}

The element is resizable and has a scrolling mechanism.

Using overflow: visible

.panel {
  width: 250px;
  height: 120px;
  overflow: visible;
  resize: both;
}

For an ordinary element, this does not enable the expected resizing behavior because visible does not satisfy the overflow requirement.

Using overflow: clip

.panel {
  width: 250px;
  height: 120px;
  overflow: clip;
  resize: both;
}

The clip value also prevents the expected resizing behavior for ordinary elements.

Important Consideration

Form controls such as <textarea> may have browser-provided resizing behavior. The overflow requirement for ordinary elements should not be assumed to apply identically to every native control.

Controlling Resize Limits

CSS sizing properties can restrict how small or large an element becomes when users resize it.

Minimum Dimensions

.resizable-panel {
  width: 250px;
  height: 140px;
  min-width: 150px;
  min-height: 80px;
  overflow: auto;
  resize: both;
}

The element cannot be manually reduced below the specified minimum dimensions.

Maximum Dimensions

.resizable-panel {
  width: 250px;
  height: 140px;
  max-width: 500px;
  max-height: 300px;
  overflow: auto;
  resize: both;
}

The maximum dimensions limit how far the user can enlarge the panel.

Combining Minimum and Maximum Sizes

.resizable-panel {
  width: 250px;
  height: 140px;
  min-width: 150px;
  max-width: 500px;
  min-height: 80px;
  max-height: 300px;
  overflow: auto;
  resize: both;
}

Responsive Width Constraints

.resizable-panel {
  width: 250px;
  max-width: 100%;
  min-height: 100px;
  overflow: auto;
  resize: both;
}

This helps prevent the panel from extending beyond the available width of its containing element.

Important Consideration

Minimum and maximum sizing rules constrain manual resizing, but other layout rules may also affect the element's final dimensions.

Resizing Textareas

The HTML <textarea> element is a common use case for the resize property. Many desktop browsers provide a resize handle for textareas by default.

Allow Vertical Resizing

textarea {
  resize: vertical;
}

Users can increase or decrease the textarea's height without changing its width.

Allow Resizing in Both Directions

textarea {
  resize: both;
}

Disable Manual Resizing

textarea {
  resize: none;
}

This removes user-controlled resizing where supported.

Set a Minimum Height

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  box-sizing: border-box;
}

The textarea can grow vertically while maintaining its available container width.

HTML Example

<label for="message">Your Message</label>
<textarea id="message" name="message" rows="5"></textarea>

Important Consideration

Disabling textarea resizing can make it harder for users to review longer content. Allow vertical resizing when the layout permits it.

resize Example

The following example demonstrates horizontal, vertical, and two-directional resizing. Drag the resize handles to change the dimensions of the panels.

HTML Example

<div class="resize-demo">
  <div class="resize-panel resize-both">
    <strong>resize: both</strong>
    <p>Drag the corner to change the width and height.</p>
  </div>
  <div class="resize-panel resize-horizontal">
    <strong>resize: horizontal</strong>
    <p>Drag the handle to change the width.</p>
  </div>
  <div class="resize-panel resize-vertical">
    <strong>resize: vertical</strong>
    <p>Drag the handle to change the height.</p>
  </div>
</div>

CSS Example

.resize-demo {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.resize-demo .resize-panel {
  width: 240px;
  height: 100px;
  max-width: 100%;
  min-width: 160px;
  min-height: 80px;
  padding: 12px;
  overflow: auto;
  border: 2px solid #64748b;
  background-color: #f1f5f9;
  box-sizing: border-box;
}
.resize-demo .resize-panel p {
  margin: 8px 0 0;
}
.resize-demo .resize-both {
  resize: both;
}
.resize-demo .resize-horizontal {
  resize: horizontal;
}
.resize-demo .resize-vertical {
  resize: vertical;
}
Browser Result
resize: both

Drag the corner to change the width and height.

resize: horizontal

Drag the handle to change the width.

resize: vertical

Drag the handle to change the height.

The first panel can be resized in both directions. The second allows horizontal resizing, while the third allows vertical resizing.

Each panel uses overflow: auto to enable resizing and provide scrolling when its content exceeds the available space.

Disabling Resizing

.resize-demo .resize-panel {
  resize: none;
}

This removes the user-controlled resize behavior from all three panels.

Adding Maximum Height

.resize-demo .resize-panel {
  max-height: 250px;
}

This limits the height of panels that support vertical resizing.

Accessibility Considerations

Resizable interfaces should remain usable for people with different input methods, visual needs, and display sizes.

Do Not Depend Only on Dragging

Native CSS resize handles may not provide consistent keyboard interaction. If resizing is essential, consider providing accessible controls for changing dimensions.

Maintain Readable Content

Set appropriate minimum dimensions so text and controls remain usable when an element is reduced in size.

Avoid Unnecessary Restrictions

Allowing textareas to expand can help users review and edit longer content.

Preserve Focus Visibility

Ensure focus indicators and interactive controls remain visible when resizable containers change dimensions.

Support Zoom and Reflow

Test resizable elements at increased zoom levels and narrow viewport widths.

Provide Clear Instructions

When manual resizing is an important feature, explain how users can adjust the element.

Important Consideration

The resize property provides browser-managed resizing behavior, but it does not guarantee an accessible resize interaction for every input method.

Common Mistakes

Forgetting the Overflow Requirement

.panel {
  width: 250px;
  height: 120px;
  resize: both;
}

For an ordinary element, the default overflow: visible generally prevents resizing. Add an appropriate overflow value.

Using overflow: clip

.panel {
  overflow: clip;
  resize: both;
}

The clip value does not satisfy the resizing requirement for ordinary elements.

Using an Unsupported Keyword

.panel {
  resize: auto;
}

Use a supported value such as both, horizontal, or vertical.

Confusing Resizing With Responsive Layout

The resize property enables manual changes by the user. It does not replace responsive sizing techniques such as percentages, Flexbox, or Grid.

Removing Useful Textarea Resizing

textarea {
  resize: none;
}

Disabling resizing may make long text difficult to review. Consider whether vertical resizing would be more appropriate.

Ignoring Minimum and Maximum Dimensions

Without suitable constraints, a resizable element may become too small to use or too large for the surrounding layout.

Expecting Consistent Resize Handles

Resize handles can differ in appearance and behavior between browsers, operating systems, and input devices.

Assuming Keyboard Resizing Is Available

Native CSS resize handles may not be keyboard accessible. Provide an alternative when resizing is necessary for completing a task.

Important Considerations

Keep the following points in mind when using resize:

  • It controls whether users can manually resize an element.
  • Its initial value is none.
  • The property is not inherited.
  • both allows horizontal and vertical resizing.
  • horizontal allows width changes.
  • vertical allows height changes.
  • block follows the logical block axis.
  • inline follows the logical inline axis.
  • Logical resizing directions depend on writing mode.
  • For ordinary elements, resizing generally requires overflow other than visible or clip.
  • overflow: auto is a common choice for resizable panels.
  • overflow: hidden can also permit resizing while clipping overflowing content.
  • Native form controls may have special resizing behavior.
  • Many desktop browsers provide textarea resize handles by default.
  • Use min-width and min-height to prevent excessive shrinking.
  • Use max-width and max-height to limit enlargement.
  • box-sizing: border-box can simplify dimension calculations.
  • Resize handles may differ between browsers and operating systems.
  • Touch devices may not provide the same resizing interaction as desktop browsers.
  • Manual resizing does not replace responsive layout techniques.
  • Resizing can affect surrounding layout and content overflow.
  • Test resizable elements at narrow viewport widths.
  • Do not rely exclusively on dragging when resizing is essential.
  • Preserve readable text and usable controls at minimum dimensions.
  • Allow textarea resizing when it improves usability.

Browser Support

The CSS resize property is Baseline Widely available and is supported in current versions of major browsers.

The commonly used none, both, horizontal, and vertical values have broad support. Support for logical values such as block and inline, as well as the availability of resize handles on touch devices, may vary.

For current compatibility information, visit Can I Use? and search for resize.

Test the property in your target browsers, particularly when resizing is an essential part of the interface.

Specifications

The resize property is defined in CSS Basic User Interface Module Level 4.

CSS Basic User Interface Module Level 4

The specification defines resizing directions, overflow requirements, and user-controlled changes to element dimensions.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: resize