clip

  • Revision slug: CSS/clip
  • Revision title: clip
  • Revision id: 364529
  • Created:
  • Creator: teoli
  • 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 {{cssxref("shape")}} 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 top border edge of the box, and <right>, and <left> specify offsets from the left border edge of the box.
<top>, <right>, <bottom>, and <left> may either have a {{ Xref_csslength() }} value or auto.
auto
The element does not clip (default value)

Examples

p { border:dotted;  position:relative; }

#img2 {
  position:absolute;  left:263px;

  clip: rect(40px, 200px, 150px, 30px); 
  /* standard syntax, unsupported by Internet Explorer 4-7 */
}

#img3 {
  position: absolute; left:526px;

  clip: rect(40px  200px  150px  30px);
  /* non-standard syntax, but supported by all major browsers including Firefox and IE */
}

hut.jpg hut.jpg hut.jpg

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)
8.0
Correct comma syntax supported in this version.
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 {{cssxref("shape")}} 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>top border edge</em> of the box, and <code>&lt;right&gt;</code>, and <code>&lt;left&gt;</code> specify offsets from the <em>left border edge</em> of the 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>.</dd>
  <dt>
    <code>auto</code></dt>
  <dd>
    The element does not clip (default value)</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre class="brush:css">
p { border:dotted;  position:relative; }

#img2 {
  position:absolute;  left:263px;

  clip: rect(40px, 200px, 150px, 30px); 
  /* standard syntax, unsupported by Internet Explorer 4-7 */
}

#img3 {
  position: absolute; left:526px;

  clip: rect(40px  200px  150px  30px);
  /* non-standard syntax, but supported by all major browsers including Firefox and IE */
}</pre>
<p style="position:relative; border:dotted"><img alt="hut.jpg" src="/@api/deki/files/3613/=hut.jpg" /> <img alt="hut.jpg" src="/@api/deki/files/3613/=hut.jpg" style="position:absolute; left:263px; clip: rect(40px, 200px, 150px, 30px)" /> <img alt="hut.jpg" src="/@api/deki/files/3613/=hut.jpg" style="position:absolute; left:526px; clip: rect(40px 200px 150px 30px)" /></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)</td>
      </tr>
      <tr>
        <td>8.0<br />
          Correct comma syntax supported in this version.</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