Revision 339103 of resize

  • Revision slug: CSS/resize
  • Revision title: resize
  • Revision id: 339103
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment CleanUp, id.

Revision Content

{{CSSRef}}

Summary

The resize CSS property lets you control the resizability of an element.

  • {{Xref_cssinitial}} none
  • Applies to block-level and replaced elements, table cells, and inline blocks
  • {{Xref_cssinherited}} no
  • Media {{Xref_cssvisual}}
  • {{Xref_csscomputed}} as specified

Syntax

resize: none | both | horizontal | vertical | inherit

Values

none
The element offers no user-controllable method for resizing the element.
both
The element displays a mechanism for allowing the user to resize the element, which may be resized both horizontally and vertically.
horizontal
The element displays a mechanism for allowing the user to resize the element, which may only be resized horizontally.
vertical
The element displays a mechanism for allowing the user to resize the element, which may only be resized vertically.
Note: resize does not apply to blocks for which the {{cssxref("overflow")}} property is set to visible.

Examples

Disabling resizability of textareas

By default, {{HTMLElement("textarea")}} elements are resizable in {{gecko("2.0")}} (Firefox 4). You may override this behavior with the CSS shown below:

textarea.example {
  resize: none; /* disables resizability */
}

Using resize with arbitrary elements

You can use the resize property to make any element resizable. In the example below, a resizable {{HTMLElement("div")}} box contains a resizable paragraph ({{HTMLElement("p")}} element):

<div style="resize:both; overflow:scroll; width:300px; height:300px; border:1px solid black">
  <p style="resize:both; overflow:scroll; width:200px; height:200px; border:1px solid black">
    This paragraph is resizable, because the CSS resize property is set to 'both' on this
    element.
  </p>
</div>

arbitrary.png

{{CSSLiveSample("resize.html")}}

Specifications

Specification Status Comment
{{SpecName('CSS3 UI', '#resize', 'resize')}} {{Spec2('CSS3 UI')}}  

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (on {{HTMLElement("textarea")}}) 1.0 {{CompatGeckoDesktop("2.0")}} {{CompatNo}} {{CompatNo}} 3.0 (522)
On any block-level and replaced element, table cell, and inline block element (unless {{cssxref("overflow")}} is visible) {{CompatNo}} {{CompatGeckoDesktop("2.0")}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (on {{HTMLElement("textarea")}}) {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
On any block-level and replaced element, table cell, and inline block element (unless {{cssxref("overflow")}} is visible) {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

See also

  • {{HTMLElement("textarea")}}

Revision Source

<div>{{CSSRef}}</div>
<h2 id="Summary">Summary</h2>
<p>The <code>resize</code> CSS property lets you control the resizability of an element.</p>
<ul class="cssprop">
  <li><dfn>{{Xref_cssinitial}}</dfn> <code>none</code></li>
  <li><dfn>Applies to</dfn> block-level and replaced elements, table cells, and inline blocks</li>
  <li><dfn>{{Xref_cssinherited}}</dfn> no</li>
  <li><dfn>Media</dfn> {{Xref_cssvisual}}</li>
  <li><dfn>{{Xref_csscomputed}}</dfn> as specified</li>
</ul>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">
resize: none | both | horizontal | vertical | inherit</pre>
<h3 id="Values">Values</h3>
<dl>
  <dt>
    none</dt>
  <dd>
    The element offers no user-controllable method for resizing the element.</dd>
  <dt>
    both</dt>
  <dd>
    The element displays a mechanism for allowing the user to resize the element, which may be resized both horizontally and vertically.</dd>
  <dt>
    horizontal</dt>
  <dd>
    The element displays a mechanism for allowing the user to resize the element, which may only be resized horizontally.</dd>
  <dt>
    vertical</dt>
  <dd>
    The element displays a mechanism for allowing the user to resize the element, which may only be resized vertically.</dd>
</dl>
<div class="note">
  <strong>Note:</strong> <code>resize</code> does not apply to blocks for which the {{cssxref("overflow")}}&nbsp;property is set to <code>visible</code>.</div>
<h2 id="Examples">Examples</h2>
<h3 id="Disabling_resizability_of_textareas">Disabling resizability of textareas</h3>
<p>By default, {{HTMLElement("textarea")}} elements are resizable in {{gecko("2.0")}} (Firefox 4). You may override this behavior with the CSS shown below:</p>
<pre class="brush: css">
textarea.example {
&nbsp; resize: none; /* disables resizability */
}
</pre>
<h3 id="Using_resize_with_arbitrary_elements">Using resize with arbitrary elements</h3>
<p>You can use the resize property to make any element resizable. In the example below, a resizable {{HTMLElement("div")}} box contains a resizable paragraph ({{HTMLElement("p")}}&nbsp;element):</p>
<pre class="brush: html">
&lt;div style="resize:both; overflow:scroll; width:300px; height:300px; border:1px solid black"&gt;
  &lt;p style="resize:both; overflow:scroll; width:200px; height:200px; border:1px solid black"&gt;
    This paragraph is resizable, because the CSS resize property is set to 'both' on this
    element.
 &nbsp;&lt;/p&gt;
&lt;/div&gt;
</pre>
<p><img alt="arbitrary.png" class="internal default" src="/@api/deki/files/4966/=arbitrary.png" /></p>
<p>{{CSSLiveSample("resize.html")}}</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('CSS3 UI', '#resize', 'resize')}}</td>
      <td>{{Spec2('CSS3 UI')}}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>Basic support (on {{HTMLElement("textarea")}})</td>
        <td>1.0</td>
        <td>{{CompatGeckoDesktop("2.0")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>3.0 (522)</td>
      </tr>
      <tr>
        <td>On any block-level and replaced element, table cell, and inline block element (unless {{cssxref("overflow")}} is <code>visible</code>)</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatGeckoDesktop("2.0")}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support (on {{HTMLElement("textarea")}})</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
      <tr>
        <td>On any block-level and replaced element, table cell, and inline block element (unless {{cssxref("overflow")}} is <code>visible</code>)</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{HTMLElement("textarea")}}</li>
</ul>
Revert to this revision