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

mozilla

Revision 69260 of <shape>

  • Revision slug: CSS/shape
  • Revision title: shape
  • Revision id: 69260
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

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)

where:

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.

Examples

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

Specifications

Specification Status Comment
CSS Level 2 (Revision 1) {{ 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") }}
  • CSS Reference index
  • CSS Data Types : {{ CSSDataTypes() }}

Revision Source

<h2 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 name="Syntax">The rect() function</h2>
<p>The rect() functional notation produces a region in the form of a rectangle.</p>
<h3>Syntax</h3>
<pre class="eval">rect(<em>top</em>, <em>right</em>, <em>bottom</em>, <em>left</em>)
</pre>
<p>where:</p>
<dl> <dt style="margin-left: 40px;"><em>top</em></dt>
</dl>
<dl> <dd style="margin-left: 40px;">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 style="margin-left: 40px;"><em>right</em></dt>
</dl>
<dl> <dd style="margin-left: 40px;">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 style="margin-left: 40px;"><em>bottom</em></dt>
</dl>
<dl> <dd style="margin-left: 40px;">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 style="margin-left: 40px;"><em>left</em></dt>
</dl>
<dl> <dd style="margin-left: 40px;">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 name="Examples">Examples</h3>
<pre class="eval"> img.clip04 { 
   clip: rect(10px, 20px, 20px, 10px);
 }
</pre>
<h2 name="Specifications">Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr style="vertical-align: top;"> <td style="vertical-align: top;"><a class="external" href="http://www.w3.org/TR/CSS21/visufx.html#value-def-shapes">CSS Level 2 (Revision 1)</a></td> <td style="vertical-align: top;">{{ Spec2('CSS2.1') }}</td> <td style="vertical-align: top;">Defined with the {{ cssxref("clip") }} property</td> </tr> </tbody>
</table>
<h2 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 name="See_also">See also</h2>
<ul> <li>Related CSS properties: {{ Cssxref("clip") }}</li> <li><a href="/en/CSS_Reference" title="CSS Reference">CSS Reference</a> index</li> <li>CSS Data Types : {{ CSSDataTypes() }}</li>
</ul>
Revert to this revision