Home CSS Properties clip CSS clip Property Definition
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.
Syntax
CSS Syntax 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.
Values
Property Values Value Description Try it autoNo clipping (default). Different from rect(auto, auto, auto, auto) Try itrect(t, r, b, l)Visible rectangle: top, right, bottom, left offsets Try itMiddle crop A smaller window inside the same box Try itNeeds position Without absolute or fixed, clip has no effect Try itinitialResets to auto Try itinheritUses the parent’s clip value Try it
Approach
How to Use clip Position first, then clip. Order matters for the property to apply.
Give the element position: absolute or fixed (and a sized containing block if needed). Set width and height so you know the box size in pixels. Add clip: rect(top, right, bottom, left) with comma-separated lengths. For new designs, switch to clip-path or overflow: hidden when a simple crop is enough. Piece Required? Role position: absolute / fixedYes Without it, clip is ignored Box size Yes (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 alternative Recommended clip-path for new code
Try it
Live Preview The blue box is position: absolute. Change only clip. The dashed frame shows the full box size.
Code
CSS Examples Each snippet focuses on clip. Position is required so the clip can apply. Use Try It Yourself for a live editor.
1. clip: auto 2. Top-left rect 3. Middle rect Example 1 — No Clipping (auto) The whole absolute box stays visible.
<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> How It Works Create a stage. A relative parent gives the absolute box a place to sit.Position the box. position: absolute is required for clip.Use the default. clip: auto means no crop — the full blue area shows.Compare later. The next examples shrink the visible rectangle.Example 2 — Top-Left Rectangle Show only the top-left quarter of the box.
<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> How It Works Keep absolute positioning. Without it, this rect() would do nothing.Read the four numbers. rect(top, right, bottom, left) with commas.Set the window. Top 0, right 96px, bottom 64px, left 0 keeps the top-left area.Hide the rest. Anything outside that rectangle is not painted.Example 3 — Middle Window Inset all four sides to show a center band.
<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> How It Works Start from the same box. Still 192×128 and absolutely positioned.Inset from the top. 32px pushes the visible top edge down.Inset from the left. 32px on the left argument; right stops at 160px.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 rectclip: 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.
Compatibility
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.
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.
Remember
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 What does the CSS clip property do? 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.
Is the CSS clip property deprecated? Yes. The CSS Masking specification deprecated clip. For new work, use clip-path instead. clip is still useful when reading older code.
What is the default value of clip? 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.
Why does clip do nothing on my element? clip only applies when position is absolute or fixed. On static, relative, or sticky elements it has no effect.
What is the difference between clip and clip-path? 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.
Which browsers support clip? 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.
About the author Developer, cloud engineer, and technical writer
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
Helpful Share Copy link Suggestion