Want to share your CSS expertise with others? Apply to the MDN Fellowship by April 1! http://mzl.la/MDNFellowship

mozilla

Revision 496039 of <shape>

  • Revision slug: Web/CSS/shape
  • Revision title: <shape>
  • Revision id: 496039
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The <shape> CSS data type denotes the specific form of a region. This region is used to define on which part of an element some properties like {{ Cssxref("clip") }} do apply.

In the current specification, a <shape>, though designed to denote any kind of form, can only represents a rectangular region, defined using the rect() functional notation.

The rect() function

The rect() functional notation produces a region in the form of a rectangle.

Syntax

rect(top, right, bottom, left)

Values

rect.png

top
Is a {{ xref_csslength() }} representing the offset for the top of the rectangle relative to the top border of the element's box.
right
Is a {{ xref_csslength() }} representing the offset for the right of the rectangle relative to the left border of the element's box.
bottom
Is a {{ xref_csslength() }} representing the offset for the bottom of the rectangle relative to the top border of the element's box.
left
Is a {{ xref_csslength() }} representing the offset for the left of the rectangle relative to the left border of the element's box.

Interpolation

Values of the <shape> CSS data type which are rectangles can be interpolated in order to allow animations. In that case they are interpolated over their top, right, bottom and left component, each treated as a real, floating-point number. The speed of the interpolation is determined by the timing function associated with the animation.

Examples

 img.clip04 { 
   clip: rect(10px, 20px, 20px, 10px);
 }

Specifications

Specification Status Comment
{{ SpecName('CSS2.1', 'visufx.html#value-def-shape', '<shape>') }} {{ Spec2('CSS2.1') }} Defined with the {{ cssxref("clip") }} property

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 {{ CompatGeckoDesktop("1.0") }} 5.5[*] 9.5 1.3
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

[*] From IE 5.5 to IE 7 included, the IE supported syntax of the rect() didn't allow the comma as the parameter separator, but a space. From IE 8, the standard syntax (only commas) is supported.

See also

  • Related CSS properties: {{ Cssxref("clip") }}
  • The -moz-image-rect() function with similar coordinate than rect().
  • CSS Data Types : {{ CSSDataTypes() }}.

Revision Source

<p name="Summary">{{ CSSRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>&lt;shape&gt;</code> <a href="/en/CSS" title="CSS">CSS</a> data type denotes the specific form of a region. This region is used to define on which part of an element some properties like {{ Cssxref("clip") }} do apply.</p>
<p>In the current specification, a <code>&lt;shape&gt;</code>, though designed to denote any kind of form, can only represents a rectangular region, defined using the <code>rect()</code> functional notation.</p>
<h2 id="Syntax" name="Syntax">The <code>rect()</code> function</h2>
<p>The <code>rect()</code> functional notation produces a region in the form of a rectangle.</p>
<h3 id="Syntax">Syntax</h3>
<pre class="eval">
rect(<em>top</em>, <em>right</em>, <em>bottom</em>, <em>left</em>)
</pre>
<h4>Values</h4>
<p><img align="right" alt="rect.png" class="internal rwrap" src="/@api/deki/files/5730/=rect.png" /></p>
<dl>
 <dt>
  <em>top</em></dt>
 <dd>
  Is a {{ xref_csslength() }} representing the offset for the top of the rectangle relative to the top border of the element's box.</dd>
</dl>
<dl>
 <dt>
  <em>right</em></dt>
 <dd>
  Is a {{ xref_csslength() }} representing the offset for the right of the rectangle relative to the left border of the element's box.</dd>
</dl>
<dl>
 <dt>
  <em>bottom</em></dt>
 <dd>
  Is a {{ xref_csslength() }} representing the offset for the bottom of the rectangle relative to the top border of the element's box.</dd>
</dl>
<dl>
 <dt>
  <em>left</em></dt>
 <dd>
  Is a {{ xref_csslength() }} representing the offset for the left of the rectangle relative to the left border of the element's box.</dd>
</dl>
<h3 id="Interpolation">Interpolation</h3>
<p>Values of the <code>&lt;shape&gt;</code> CSS data type which are rectangles can be interpolated in order to allow animations. In that case they are interpolated over their <code>top</code>, <code>right</code>, <code>bottom</code> and <code>left</code> component, each treated as a real, floating-point number. The speed of the interpolation is determined by the <a href="/en/CSS/timing-function" title="timing-function">timing function</a> associated with the animation.</p>
<h3 id="Examples" name="Examples">Examples</h3>
<pre class="eval">
 img.clip04 { 
   clip: rect(10px, 20px, 20px, 10px);
 }
</pre>
<h2 id="Specifications" name="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('CSS2.1', 'visufx.html#value-def-shape', '&lt;shape&gt;') }}</td>
   <td>{{ Spec2('CSS2.1') }}</td>
   <td>Defined with the {{ cssxref("clip") }} property</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</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>{{ CompatGeckoDesktop("1.0") }}</td>
    <td>5.5[*]</td>
    <td>9.5</td>
    <td>1.3</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 Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<p>[*] From IE 5.5 to IE 7 included, the IE supported syntax of the rect() didn't allow the comma as the parameter separator, but a space. From IE 8, the standard syntax (only commas) is supported.</p>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li>Related CSS properties: {{ Cssxref("clip") }}</li>
 <li>The <a href="/en/CSS/-moz-image-rect" title="en/CSS/-moz-image-rect">-moz-image-rect()</a> function with similar coordinate than <code>rect()</code>.</li>
 <li>CSS Data Types : {{ CSSDataTypes() }}.</li>
</ul>
Revert to this revision