CSS Portal

CSS perspective Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The perspective property establishes a 3D space for an element’s descendants and controls how those descendants are projected onto the 2D rendering surface. Conceptually, it defines the distance between the user and the z=0 plane of that local 3D space, which determines how much foreshortening and depth distortion are applied to elements that are transformed in three dimensions. When you set this property on a container, its children that use 3D transforms are rendered as if seen from a point in front of (or behind) that container, creating the familiar vanishing-point effect. The point around which that perspective projects can be adjusted with perspective-origin.

It’s important to understand how this differs from applying a perspective via the transform functions. A transform that uses a perspective value (the perspective() function) applies that projection to the element being transformed itself, whereas the perspective property on a parent creates a shared 3D context that influences all of its transformed descendants. Because of that, the same visual result can be achieved in different ways depending on whether you want the projection to be local to a single element or shared among a group of children.

For nested 3D content to retain true depth relationships, you often need to allow children to keep their 3D rendering inside their transformed parents. That behavior is controlled by transform-style. When a parent’s transform flattening would otherwise collapse its children into the parent's plane, enabling the appropriate 3D-preserving mode ensures the perspective-established depth is visible throughout the descendant chain. In practice, use perspective on an ancestor when you want a consistent camera-like view of multiple transformed elements, and use transform-based perspective when you need a per-element, localized projection.

Definition

Initial value
none
Applies to
Transformable elements
Inherited
No
Computed value
Absolute length or 'none'.
Animatable
As <length>
JavaScript syntax
object.style.perspective

Interactive Demo

front
back
right
left
top
bottom

Syntax

perspective: none | <length>

Values

  • noneNo perspective transform is applied.
  • <length>Distance to the center of projection.

Example

<div class="scene">
<div class="card" tabindex="0">
<div class="face front">Front</div>
<div class="face back">Back</div>
</div>
</div>
body {
    margin: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
}

.scene {
    width: 220px;
    height: 300px;
    perspective: 900px; /* <- the perspective property */
    perspective-origin: 50% 40%;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 12px 30px rgba(16, 24, 40, 0.12);
    border-radius: 12px;
    cursor: pointer;
}

.scene:hover .card {
    transform: rotateY(180deg);
}

.face {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    font-size: 1.25rem;
    color: white;
}

.front {
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
}

.back {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    transform: rotateY(180deg);
}

/* small hint when focused (keyboard) */
.card:focus {
    outline: 4px solid rgba(99, 102, 241, 0.12);
    outline-offset: 6px;
}

Browser Support

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

This property 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
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!