CSS clip Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The clip property shows only a rectangle of an element and hides the rest. It works only on elements with position: absolute or fixed.

You set the rectangle with the old rect(top, right, bottom, left) form. For new projects, prefer clip-path.

Deprecated.

Avoid clip in new work. CSS Masking deprecated it in favor of clip-path. Study it to read legacy CSS and understand rectangular clipping.

CSS Syntax

syntax.css
clip: auto | rect(top, right, bottom, left) | initial | inherit;

The initial value is auto. In rect(), top and bottom are offsets from the top border edge; right and left are offsets from the left border edge.

Property Values

ValueDescriptionTry it
autoNo clipping (default). Different from rect(auto, auto, auto, auto)Try it
rect(t, r, b, l)Visible rectangle: top, right, bottom, left offsetsTry it
Middle cropA smaller window inside the same boxTry it
Needs positionWithout absolute or fixed, clip has no effectTry it
initialResets to autoTry it
inheritUses the parent’s clip valueTry it

How to Use clip

Position first, then clip. Order matters for the property to apply.

  1. Give the element position: absolute or fixed (and a sized containing block if needed).
  2. Set width and height so you know the box size in pixels.
  3. Add clip: rect(top, right, bottom, left) with comma-separated lengths.
  4. For new designs, switch to clip-path or overflow: hidden when a simple crop is enough.
PieceRequired?Role
position: absolute / fixedYesWithout it, clip is ignored
Box sizeYes (to plan the rect)Offsets are measured inside this box
rect(t, r, b, l)Yes (to crop)Comma-separated; old clip form only
Modern alternativeRecommendedclip-path for new code

Live Preview

The blue box is position: absolute. Change only clip. The dashed frame shows the full box size.

rect(top, right, bottom, left) — distances from the top and left edges of the box.

Box

clip: rect(0px, 96px, 64px, 0px)

CSS Examples

Each snippet focuses on clip. Position is required so the clip can apply. Use Try It Yourself for a live editor.

Example 1 — No Clipping (auto)

The whole absolute box stays visible.

CSS
<style>
  .stage { position: relative; width: 192px; height: 128px; border: 1px dashed #94a3b8; }
  .box {
    position: absolute;
    top: 0; left: 0;
    width: 192px; height: 128px;
    background: #2563eb;
    color: #fff;
    clip: auto;
  }
</style>

<div class="stage">
  <div class="box">Full box</div>
</div>
Try It Yourself

How It Works

  1. Create a stage. A relative parent gives the absolute box a place to sit.
  2. Position the box. position: absolute is required for clip.
  3. Use the default. clip: auto means no crop — the full blue area shows.
  4. Compare later. The next examples shrink the visible rectangle.

Example 2 — Top-Left Rectangle

Show only the top-left quarter of the box.

CSS
<style>
  .stage { position: relative; width: 192px; height: 128px; border: 1px dashed #94a3b8; }
  .box {
    position: absolute;
    top: 0; left: 0;
    width: 192px; height: 128px;
    background: #2563eb;
    color: #fff;
    clip: rect(0, 96px, 64px, 0);
  }
</style>

<div class="stage">
  <div class="box">Top-left</div>
</div>
Try It Yourself

How It Works

  1. Keep absolute positioning. Without it, this rect() would do nothing.
  2. Read the four numbers. rect(top, right, bottom, left) with commas.
  3. Set the window. Top 0, right 96px, bottom 64px, left 0 keeps the top-left area.
  4. Hide the rest. Anything outside that rectangle is not painted.

Example 3 — Middle Window

Inset all four sides to show a center band.

CSS
<style>
  .stage { position: relative; width: 192px; height: 128px; border: 1px dashed #94a3b8; }
  .box {
    position: absolute;
    top: 0; left: 0;
    width: 192px; height: 128px;
    background: #2563eb;
    color: #fff;
    clip: rect(32px, 160px, 96px, 32px);
  }
</style>

<div class="stage">
  <div class="box">Middle</div>
</div>
Try It Yourself

How It Works

  1. Start from the same box. Still 192×128 and absolutely positioned.
  2. Inset from the top. 32px pushes the visible top edge down.
  3. Inset from the left. 32px on the left argument; right stops at 160px.
  4. Bottom closes the window. 96px from the top finishes the visible band.

Edge Cases & Pitfalls

If clipping fails, check these first.

position

Must be absolute or fixed

On static, relative, or sticky, clip is ignored. Set position: absolute or fixed first.

order

rect is top, right, bottom, left

The old clip form uses commas: rect(top, right, bottom, left). Do not confuse it with the modern CSS shapes rect() used elsewhere.

auto

auto ≠ all-auto rect

clip: auto means no clipping. rect(auto, auto, auto, auto) clips to the inside border edges.

legacy

Prefer clip-path for new code

clip is deprecated and rectangle-only. Use clip-path for circles, polygons, and maintainable clipping.

overflow

Simple crop alternatives

For a box that just hides overflowing children, overflow: hidden is often enough and does not need absolute positioning.

Browser Support

clip is a browser CSS property (deprecated). Node.js, Deno, and Bun do not apply it.

✓ Deprecated · Still widely supported

clip

Supported across modern browsers and Internet Explorer, but deprecated. Prefer clip-path for new projects.

99% Legacy browser reach
Google Chrome 1+
Supported (deprecated)
Mozilla Firefox 1+
Supported (deprecated)
Apple Safari 1+
Supported (deprecated)
Microsoft Edge 12+
Supported (deprecated)
Opera 7+
Supported (deprecated)
Samsung Internet 1+
Supported (deprecated)
Internet Explorer 4+
Supported (deprecated)
clip (deprecated) Widely supported

Bottom line: Still works for legacy pages, but do not choose clip for new UI. Migrate to clip-path. It is not a runtime API.

Key Takeaways

  • Role: show a rectangle of an absolute/fixed element; hide the rest.
  • Syntax: clip: rect(top, right, bottom, left); with commas.
  • Deprecated: use clip-path for new projects.
  • Initial value: auto. Not inherited. Needs absolute or fixed position.

One line: absolute/fixed + clip: rect(t, r, b, l) = rectangular crop; prefer clip-path going forward.

Frequently Asked Questions

It hides everything outside a rectangle on an absolutely or fixed positioned element. Only the area inside clip: rect(top, right, bottom, left) stays visible.
Yes. The CSS Masking specification deprecated clip. For new work, use clip-path instead. clip is still useful when reading older code.
The initial value is auto, which means no clipping. That is different from rect(auto, auto, auto, auto), which clips to the element’s inside border edges.
clip only applies when position is absolute or fixed. On static, relative, or sticky elements it has no effect.
clip only supports a rectangle via the old rect() form and needs absolute/fixed positioning. clip-path supports circles, polygons, and more shapes and is the modern replacement.
Despite being deprecated, clip is widely supported in browsers, including Internet Explorer. Prefer clip-path for new projects. It is a browser CSS property, not a Node.js feature.

Next: clip-path

Clip with circles, polygons, and inset shapes the modern way.

clip-path tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful