Spec-Zone.ru › CSS

`clip` CSS property

Baseline Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Warning: Authors are encouraged to use the clip-path property instead.

The clip CSS property defines a visible portion of an element. The clip property applies only to absolutely positioned elements — that is, elements with position:absolute or position:fixed.

Syntax

/* Keyword value */
clip: auto;

/* <shape> values */
clip: rect(1px, 10em, 3rem, 2ch);

/* Global values */
clip: inherit;
clip: initial;
clip: revert;
clip: revert-layer;
clip: unset;

Values

This property is specified as a single value from the following list:

rect()

A rectangle defined using a rect() function of the form rect(<top>, <right>, <bottom>, <left>). The <top> and <bottom> values are offsets from the inside top border edge of the box, while <right> and <left> are offsets from the inside left border edge of the box — that is, the extent of the padding box.

The <top>, <right>, <bottom>, and <left> values may be either a <length> or auto. If any side's value is auto, the element is clipped to that side's inside border edge.

Note: The rect() <shape> function used in the deprecated clip property is different from the CSS rect() function used to define a CSS <basic-shape>.

auto
The element does not clip (default). This is different from rect(auto, auto, auto, auto), which clips to the element's inside border edges.

Formal definition

Initial value auto
Applies to absolutely positioned elements
Inherited no
Computed value <code>auto</code> if specified as <code>auto</code>, otherwise a rectangle with four values, each of which is <code>auto</code> if specified as <code>auto</code> or the computed length otherwise
Animation type a <a href="/en-US/docs/Web/CSS/Reference/Values/shape#interpolation" title="Values of the <shape> CSS data type which are rectangles are interpolated over their top, right, bottom and left component, each treated as a real, floating-point number.">rectangle</a>

Formal syntax

clip = 
  <shape> |
  auto

<shape> = 
  rect(<top>, <right>, <bottom>, <left>)

Examples

Clipping an image

<p class="dotted-border">
  <img src="macarons.png" alt="Original graphic" />
  <img id="top-left" src="macarons.png" alt="Graphic clipped to upper left" />
  <img id="middle" src="macarons.png" alt="Graphic clipped towards middle" />
  <img
    id="bottom-right"
    src="macarons.png"
    alt="Graphic clipped to bottom right" />
</p>
.dotted-border {
  border: dotted;
  position: relative;
  width: 390px;
  height: 400px;
}

#top-left,
#middle,
#bottom-right {
  position: absolute;
  top: 0;
}

#top-left {
  left: 400px;
  clip: rect(0, 130px, 90px, 0);
}

#middle {
  left: 270px;
  clip: rect(100px, 260px, 190px, 130px);
}

#bottom-right {
  left: 140px;
  clip: rect(200px, 390px, 290px, 260px);
}

Specifications

Specification
CSS Masking Module Level 1
# propdef-clip

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS
clip
1
12
1
7
1Safari incorrectly interprets clip: auto as clip: rect(auto, auto, auto, auto).
18
4
14
1Safari on iOS incorrectly interprets clip: auto as clip: rect(auto, auto, auto, auto).
1.0
4.4
1WebView on iOS incorrectly interprets clip: auto as clip: rect(auto, auto, auto, auto).
auto
1
79
1
15
1
18
4
14
1
1.0
4.4
1

See also

  • clip-path
  • position
  • mask
  • shape-image-threshold
  • shape-outside

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/clip

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API