CSS perspective Property

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

Definition and Usage

The perspective property sets the distance between the viewer and the z=0 plane. Put it on a parent. Children that use 3D transform values such as rotateY() then look foreshortened instead of flat.

Smaller lengths look stronger. Larger lengths look subtler. Move the vanishing point with perspective-origin. This property is not the same as the perspective() transform function, which applies depth to the transformed element itself.

Standard-track.

Not deprecated. Baseline widely available. A value other than none creates a stacking context and a containing block for position: fixed descendants.

CSS Syntax

syntax.css
perspective: none | <length> | initial | inherit;

Lengths must be non-negative. Values under 1px clamp to 1px. Negative lengths are invalid.

Property Values

ValueDescriptionTry it
noneDefault. No 3D viewing distance for childrenTry it
<length>Viewing distance such as 500px or 40remTry it
200pxCloser viewer — stronger foreshorteningTry it
1000pxFarther viewer — subtler depthTry it
initialResets to noneTry it
inheritTakes the parent’s perspectiveTry it

How to Use perspective

Frame a scene on the parent, then rotate or translate a child in 3D.

  1. Set perspective on the parent container (not usually on the rotated element).
  2. Give a child a 3D transform such as rotateY(45deg) or translateZ().
  3. Tune the length: start near 500px, then try shorter for drama or longer for subtlety.
  4. Adjust the vanishing point with perspective-origin when the scene should skew off-center.
PieceRequired?Role
Parent with perspectiveYesCreates the 3D viewing distance for children
Child 3D transformYesSomething to foreshorten (rotateY, rotateX, translateZ)
perspective-originNoMoves the vanishing point (default is center)
transform-style: preserve-3dSometimesNeeded when nested children must stay in true 3D space

Live Preview

Same card, same rotateY(45deg). Change only the parent’s perspective.

Shorter lengths look stronger. none leaves the turn looking flat.

Scene

perspective: 500px — Balanced depth for a 45° turn.

CSS Examples

Each snippet focuses on perspective. Use Try It Yourself for a live editor.

Example 1 — Parent Distance, Child Turn

Put perspective on the parent. Rotate the child with rotateY.

CSS
<style>
  section {
    perspective: 500px;
  }

  div {
    width: 120px;
    height: 80px;
    background: #1d4ed8;
    color: #fff;
    text-align: center;
    line-height: 80px;
    transform: rotateY(45deg);
  }
</style>

<section>
  <div>Card</div>
</section>
Try It Yourself

How It Works

  1. Frame the scene. perspective: 500px on section sets the viewing distance for children.
  2. Turn the child. rotateY(45deg) swings the card around the Y axis.
  3. See foreshortening. Because the parent has a length, the near side of the card looks wider than the far side.
  4. Keep styling light. Width, height, color, and line-height only make the card readable. Depth comes from perspective.

Example 2 — Near vs Far

Same turn. A short length looks dramatic; a long length looks quiet.

CSS
<style>
  .near {
    perspective: 200px;
  }

  .far {
    perspective: 1000px;
  }

  div {
    width: 120px;
    height: 80px;
    background: #1d4ed8;
    color: #fff;
    text-align: center;
    line-height: 80px;
    transform: rotateY(45deg);
  }
</style>

<section class="near">
  <div>Near</div>
</section>

<section class="far">
  <div>Far</div>
</section>
Try It Yourself

How It Works

  1. Keep the turn fixed. Both cards use the same rotateY(45deg).
  2. Move the viewer closer. 200px makes the foreshortening strong.
  3. Move the viewer farther. 1000px softens the same angle.
  4. Pick for the UI. Cards and hero tiles often sit near 500px–900px; tiny lengths can look extreme.

Example 3 — No Perspective

With none, the same rotateY looks flat.

CSS
<style>
  section {
    perspective: none;
  }

  div {
    width: 120px;
    height: 80px;
    background: #1d4ed8;
    color: #fff;
    text-align: center;
    line-height: 80px;
    transform: rotateY(45deg);
  }
</style>

<section>
  <div>Flat</div>
</section>
Try It Yourself

How It Works

  1. Use the default. perspective: none is the initial value.
  2. Keep the transform. rotateY(45deg) still runs, so the box changes shape in 2D projection.
  3. Lose foreshortening. Without a viewing distance, near and far edges do not scale differently.
  4. Compare with Example 1. The only meaningful change between a deep look and a flat look is the parent length.

Edge Cases & Pitfalls

If depth looks missing, one of these is usually why.

parent

Put it on the parent

perspective affects children. Setting it only on the rotated element does not create that element’s own viewing distance the way perspective() does.

length

Shorter means stronger

Students often expect larger numbers to look more 3D. The opposite is true: 200px is more dramatic than 1200px.

stacking

Not none creates a stacking context

Any length also makes the element a containing block for position: fixed descendants. That can pin overlays inside the scene unexpectedly.

origin

Vanishing point defaults to center

Use perspective-origin when the scene should skew from a corner or off-center point.

nested

Nested 3D needs preserve-3d

Parent perspective alone is not enough for multi-face cards. Set transform-style: preserve-3d on the element that turns, and often backface-visibility: hidden on each face.

Browser Support

perspective is a browser CSS property for 3D transforms. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since Sep 2015

perspective

Unprefixed: Chrome 36+, Firefox 16+, Safari 9+, Edge 12+, Opera 23+. Internet Explorer 10 supports the property. Older WebKit builds need a prefix.

97% Modern browser support
Google Chrome 36+ · 12+ with -webkit-
Full support
Mozilla Firefox 16+
Full support
Apple Safari 9+ · 4+ with -webkit-
Full support
Microsoft Edge 12+
Full support
Opera 23+
Full support
Samsung Internet 3+
Full support
Internet Explorer 10+
Full support
perspective Widely supported

Bottom line: Safe for everyday use without prefixes in current browsers. Legacy WebKit needed -webkit-perspective. Internet Explorer 10 supports the property but has limited preserve-3d behavior for nested scenes.

Key Takeaways

  • Role: set viewing distance on a parent so children’s 3D transforms show depth.
  • Common values: none and lengths such as 500px.
  • Initial value: none. Not inherited.
  • Rule of thumb: smaller length → stronger effect; pair with perspective-origin when needed.

One line: perspective on the parent is what makes a child rotateY look 3D instead of flat.

Frequently Asked Questions

It sets how far the viewer sits from the z=0 plane. Children with 3D transforms such as rotateY then look foreshortened instead of flat.
Put it on the parent that frames the scene. The property creates a 3D viewing context for that element's children, not for the element itself.
The initial value is none. With none, 3D transforms on children look flat because no viewing distance is applied.
A short length such as 200px places the viewer closer to the scene, so the same rotateY looks more dramatic. A large length such as 1000px looks subtler.
No. The perspective property is set on a parent and affects children. The perspective() transform function applies depth to the transformed element itself.
It is Baseline and widely available since September 2015: Chrome 36+, Firefox 16+, Safari 9+, Edge 12+, IE 10+. It is a browser CSS property, not a Node.js feature.

Next: perspective-origin

Learn how to move the vanishing point for your 3D scene.

perspective-origin 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.

8 people found this page helpful