Revision 615169 of clip

  • Revision slug: Web/CSS/clip
  • Revision title: clip
  • Revision id: 615169
  • Created:
  • Creator: Martyr2
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The clip CSS property defines what portion of an element is visible. The clip property applies only to elements with {{ cssxref("position","position:absolute") }}.

{{cssbox("clip")}}

Syntax

Formal syntax: {{csssyntax("clip")}}
clip: rect(1px, 10em, 3rem, 2ch)
clip: auto

clip: inherit

Values

<shape>
A rectangular {{xref_cssshape}} of the form
rect(<top>, <right>, <bottom>, <left>)   /* standard syntax */
or
rect(<top> <right> <bottom> <left>)      /* backwards compatible syntax */
where <top> and <bottom> specify offsets from the inside top border edge of the box, and <right>, and <left> specify offsets from the inside left border edge of the box — that is, the extent of the padding box.
<top>, <right>, <bottom>, and <left> may either have a {{ Xref_csslength() }} value or auto. If any side's value is auto, the element is clipped to that side's inside border edge.
auto
The element does not clip (default value). Note that this is distinct from rect(auto, auto, auto, auto), which does clip to the inside border edges of the element.

Examples

.dotted-border { 
   border: dotted;  
   position: relative; 
   width: 610px;
}

#top-left {
   position: absolute;
   left: 360px;
   top: 0px;

   clip: rect(0px, 175px, 113px, 0px); 
}


#middle {
   position: absolute;
   left: 280px;
   top: 0px;

   clip: rect(119px, 255px, 229px, 80px); 
   /* standard syntax, unsupported by Internet Explorer 4-7 */
}

#bottom-right {
   position: absolute; 
   left: 200px;
   top: 0px;

   clip: rect(235px, 335px, 345px, 160px);
   /* non-standard syntax, but supported by all major browsers including Firefox and IE */
}
<p class="dotted-border">
   <img src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Original Graphic" /> 
   <img id="top-left" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to upper left"> 
   <img id="middle" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped towards middle"> 
   <img id="bottom-right" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to bottom right">
</p>

{{EmbedLiveSample('Examples', '679px', '410px')}}

Specifications

Specification Status Comment
{{ SpecName('CSS3 Transitions', '#animatable-css', 'clip') }} {{ Spec2('CSS3 Transitions') }} Defines clip as animatable.
{{ SpecName('CSS2.1', 'visufx.html#clipping', 'clip') }} {{ Spec2('CSS2.1') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 1.0 (1.0) 4.0 7.0 1.0 (85)
Older versions of Safari (up to at least 5.1.7) incorrectly interpret clip: auto as clip: rect(auto, auto, auto, auto).
8.0
Correct comma syntax supported in this version. Version 8 and below incorrectly interpret clip: auto as clip: rect(auto, auto, auto, auto).
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

  • Related CSS properties: {{ cssxref("text-overflow") }}, {{ cssxref("white-space") }}, {{ Cssxref("overflow-x") }}, {{ Cssxref("overflow-y") }}, {{ Cssxref("overflow") }}, {{ Cssxref("display") }}, {{ Cssxref("position") }}

Revision Source

<div>
 {{ CSSRef() }}</div>
<h2 id="Summary">Summary</h2>
<p>The <code>clip</code> CSS property defines what portion of an element is visible. The <code>clip</code> property applies only to elements with {{ cssxref("position","position:absolute") }}.</p>
<p>{{cssbox("clip")}}</p>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("clip")}}
</pre>
<pre>
clip: rect(1px, 10em, 3rem, 2ch)
clip: auto

clip: inherit</pre>
<h3 id="Values">Values</h3>
<dl>
 <dt>
  <code>&lt;shape&gt;</code></dt>
 <dd>
  A rectangular {{xref_cssshape}} of the form
  <pre style="margin:0">
rect(&lt;top&gt;, &lt;right&gt;, &lt;bottom&gt;, &lt;left&gt;)   /* standard syntax */
</pre>
  or
  <pre style="margin:0">
rect(&lt;top&gt; &lt;right&gt; &lt;bottom&gt; &lt;left&gt;)      /* backwards compatible syntax */</pre>
  where <code>&lt;top&gt;</code> and <code>&lt;bottom&gt;</code> specify offsets from the <em>inside top border edge</em> of the box, and <code>&lt;right&gt;</code>, and <code>&lt;left&gt;</code> specify offsets from the <em>inside left border edge</em> of the box — that is, the extent of the padding box.</dd>
 <dd>
  <code>&lt;top&gt;</code>, <code>&lt;right&gt;</code>, <code>&lt;bottom&gt;</code>, and <code>&lt;left&gt;</code> may either have a {{ Xref_csslength() }} value or<code> auto</code>. If any side's value is <code>auto</code>, the element is clipped to that side's <em>inside border edge</em>.</dd>
 <dt>
  <code>auto</code></dt>
 <dd>
  The element does not clip (default value). Note that this is distinct from <code>rect(auto, auto, auto, auto)</code>, which does clip to the inside border edges of the element.</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush:css">
.dotted-border { 
   border: dotted;  
   position: relative; 
   width: 610px;
}

#top-left {
   position: absolute;
   left: 360px;
   top: 0px;

   clip: rect(0px, 175px, 113px, 0px); 
}


#middle {
   position: absolute;
   left: 280px;
   top: 0px;

   clip: rect(119px, 255px, 229px, 80px); 
   /* standard syntax, unsupported by Internet Explorer 4-7 */
}

#bottom-right {
   position: absolute; 
   left: 200px;
   top: 0px;

   clip: rect(235px, 335px, 345px, 160px);
   /* non-standard syntax, but supported by all major browsers including Firefox and IE */
}</pre>
<pre class="brush:html">
&lt;p class="dotted-border"&gt;
   &lt;img src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Original Graphic" /&gt; 
   &lt;img id="top-left" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to upper left"&gt; 
   &lt;img id="middle" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped towards middle"&gt; 
   &lt;img id="bottom-right" src="https://developer.mozilla.org/@api/deki/files/3613/=hut.jpg" title="Graphic clipped to bottom right"&gt;
&lt;/p&gt;</pre>
<p>{{EmbedLiveSample('Examples', '679px', '410px')}}</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 Transitions', '#animatable-css', 'clip') }}</td>
   <td>{{ Spec2('CSS3 Transitions') }}</td>
   <td>Defines <code>clip</code> as animatable.</td>
  </tr>
  <tr>
   <td>{{ SpecName('CSS2.1', 'visufx.html#clipping', 'clip') }}</td>
   <td>{{ Spec2('CSS2.1') }}</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 rowspan="2">Basic support</td>
    <td rowspan="2">1.0</td>
    <td rowspan="2">1.0 (1.0)</td>
    <td>4.0</td>
    <td rowspan="2">7.0</td>
    <td rowspan="2">1.0 (85)<br />
     Older versions of Safari (up to at least 5.1.7) incorrectly interpret <code>clip: auto</code> as <code>clip: rect(auto, auto, auto, auto)</code>.</td>
   </tr>
   <tr>
    <td>8.0<br />
     Correct comma syntax supported in this version. Version 8 and below incorrectly interpret <code>clip: auto</code> as <code>clip: rect(auto, auto, auto, auto)</code>.</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</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>Related CSS properties: {{ cssxref("text-overflow") }}, {{ cssxref("white-space") }}, {{ Cssxref("overflow-x") }}, {{ Cssxref("overflow-y") }}, {{ Cssxref("overflow") }}, {{ Cssxref("display") }}, {{ Cssxref("position") }}</li>
</ul>
Revert to this revision