Favorites

CSS <shape> Data Type

<shape>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <shape> data type is the rect() shape used by the deprecated clip property. Use clip-path with a <basic-shape> instead.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <shape> CSS data type defines the region used by the deprecated clip property. Its only form is the rect() function, written with four lengths or auto values that give the top, right, bottom and left edges of the visible rectangle. Everything outside that rectangle is hidden.

The values are measured from the top-left corner of the element's border box: the top and bottom values are distances from the top edge, and the left and right values are distances from the left edge. auto means the matching edge of the border box. The original syntax separated the values with commas, but space-separated values are also accepted. The clip property only works on absolutely or fixed positioned elements.

Both <shape> and the clip property are deprecated. They still work in all browsers for backwards compatibility, most commonly in the "visually hidden" pattern for screen-reader-only text, but new code should use clip-path with a <basic-shape> such as inset() or rect(), which works on any element and supports rounded corners.

Examples:

/* Deprecated: show a 100x60 region of an absolutely positioned image */
.crop {
  position: absolute;
  clip: rect(10px, 110px, 70px, 10px);
}

/* Modern equivalent with clip-path */
.crop-modern {
  clip-path: rect(10px 110px 70px 10px);
}

/* Common visually-hidden pattern */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

Interactive Demo

Sunset
Demo Code
HTML Code
<div class="demo-frame">
	<img class="demo-element" src="/css-properties/images/sunset.jpg" alt="Sunset">
</div>
CSS Code
.demo-frame {
	position: relative;
	width: 260px;
	height: 170px;
	outline: 1px dashed #b0b0b0;
}
.demo-element {
	position: absolute;
	top: 0;
	left: 0;
	width: 260px;
	height: 170px;
	object-fit: cover;
	clip: rect(0, 260px, 170px, 0);
}

Syntax

<shape> = rect( <top>, <right>, <bottom>, <left> )
where each value is a <length> or auto

Values

  • <top>The distance of the top edge of the visible area from the top of the border box, or auto (0).
  • <right>The distance of the right edge from the left of the border box, or auto (the full width).
  • <bottom>The distance of the bottom edge from the top of the border box, or auto (the full height).
  • <left>The distance of the left edge from the left of the border box, or auto (0).

Example

<div class="wrap">
<h1>CSS &lt;shape&gt; examples</h1>
<div class="grid">
<div class="card">
<div class="frame"><div class="img"></div></div>
<div class="label">no clipping</div>
</div>
<div class="card">
<div class="frame"><div class="img clipped"></div></div>
<div class="label">clip: rect(20px, 150px, 120px, 30px)</div>
</div>
<div class="card">
<div class="frame"><div class="img modern"></div></div>
<div class="label">clip-path: rect(20px 150px 120px 30px round 10px)</div>
</div>
</div>
<p class="note">clip and &lt;shape&gt; are deprecated; clip-path is the modern replacement.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f5f7fb;
  color: #102a43;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 12px;
  color: #486581;
  margin-top: 10px;
  word-break: break-word;
}

.note {
  font-size: 13px;
  color: #486581;
  margin-top: 14px;
}

/*  examples */
.frame {
  position: relative;
  height: 160px;
  border-radius: 6px;
  background: repeating-conic-gradient(#e2e8f0 0 25%, #fff 0 50%) 0 0 / 16px 16px;
}

.img {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background:
    radial-gradient(circle at 30% 30%, #fde047 0 18%, transparent 19%),
    linear-gradient(160deg, #38bdf8 0 55%, #16a34a 55%);
}

/* Deprecated clip with a  */
.clipped {
  clip: rect(20px, 150px, 120px, 30px);
}

/* Modern equivalent */
.modern {
  clip-path: rect(20px 150px 120px 30px round 10px);
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS shape data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.