CSS transform-style Property

Beginner
⏱️ 7 min read
📚 Updated: Jun 2026
🎯 4 Examples
Transforms

What You’ll Learn

The transform-style property decides whether nested elements stay in 3D space or get flattened — essential for cubes, flips, and layered 3D scenes.

01

3D space

Child depth.

02

flat

Default.

03

preserve-3d

Keep depth.

04

Nested

Parent/child.

05

perspective

View depth.

06

Cubes

6 faces.

Introduction

The transform-style property in CSS is used to specify how nested elements are rendered in 3D space. It determines whether the children of an element are flattened into the plane of the element itself or whether they retain their 3D position relative to the parent.

This property is particularly useful when working with 3D transforms and creating 3D effects on web pages.

Definition and Usage

Use transform-style: preserve-3d on a parent container when child elements each have their own 3D transforms and must appear as one cohesive 3D object — like a cube made from six faces.

💡
Beginner Tip

With the default flat value, child 3D transforms may look collapsed. Switch the parent to preserve-3d and add perspective on an ancestor to reveal true depth.

📝 Syntax

The syntax for the transform-style property is simple. It can be applied to any element that supports transforms.

syntax.css
element {
  transform-style: value;
}

Basic Example

transform-style.css
.cube {
  transform-style: preserve-3d;
  transform: rotateX(45deg) rotateY(45deg);
}

Syntax Rules

  • Only two keyword values: flat and preserve-3d.
  • Apply on the direct parent of 3D-transformed children.
  • Pair with perspective on a parent for visible depth.
  • Child faces usually need position: absolute and their own transform.
  • The property is not inherited.

Related Properties

  • transform — moves and rotates elements in 2D/3D
  • perspective — sets viewing distance for 3D scenes
  • transform-origin — sets the pivot for transforms
  • backface-visibility — hides the reverse side during 3D flips

🎯 Default Value

The default value of the transform-style property is flat. This means that by default, the children of an element are rendered in the 2D plane of the parent element.

⚡ Quick Reference

QuestionAnswer
Default valueflat
Keep 3D childrentransform-style: preserve-3d;
Flatten childrentransform-style: flat;
Often paired withperspective and child transform
Common use case3D cubes and card flips
InheritedNo

💎 Property Values

The transform-style property accepts two keyword values.

ValueExampleDescription
flattransform-style: flat;This value indicates that the children of the element are flattened into the 2D plane of the element.
preserve-3dtransform-style: preserve-3d;This value indicates that the children of the element should retain their 3D position relative to the parent element.
flat preserve-3d

When to Use transform-style

transform-style is required when nested elements must share one 3D scene:

  • 3D cubes and boxes — Six faces positioned with translateZ and rotations.
  • Card flip animations — Front and back faces rotate in 3D space.
  • Layered 3D galleries — Multiple panels at different Z depths.
  • Product showcases — Rotating objects built from child elements.

👀 Live Preview

Two simplified scenes with front and back faces — preserve-3d keeps depth visible:

flat
preserve-3d

Examples Gallery

In this example, we’ll create a 3D cube using the transform-style property set to preserve-3d to maintain the 3D positioning of the cube faces.

📜 3D Structures

Build multi-face objects that rotate as one unit in 3D space.

Example 1 — 3D cube with preserve-3d

In this example, we’ll create a 3D cube using the transform-style property set to preserve-3d to maintain the 3D positioning of the cube faces.

index.html
<style>
  .cube {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(45deg) rotateY(45deg);
  }
  .cube-face {
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(255, 0, 0, 0.5);
    border: 1px solid #000;
  }
  .front { transform: translateZ(50px); }
  /* back, left, right, top, bottom faces... */
</style>

<div class="cube">
  <div class="cube-face front"></div>
  <!-- other faces -->
</div>
Try It Yourself

How It Works

Each face is absolutely positioned and moved with 3D transforms. preserve-3d on the parent keeps all faces in the same 3D coordinate system.

Example 2 — flat vs preserve-3d

See why child faces collapse without preserve-3d on the parent container.

compare.css
.scene-flat {
  transform-style: flat;
  transform: rotateY(45deg);
}

.scene-3d {
  transform-style: preserve-3d;
  transform: rotateY(45deg);
}
Try It Yourself

How It Works

Both parents rotate, but only preserve-3d lets child translateZ values create visible depth.

📄 UI Patterns

Use preserve-3d for flips and scene wrappers in interactive components.

Example 3 — Flip card with preserve-3d

A card container preserves 3D space so front and back faces rotate together.

flip-card.css
.flip-inner {
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.flip-card:hover .flip-inner {
  transform: rotateY(180deg);
}
Try It Yourself

How It Works

preserve-3d on the inner wrapper keeps both faces in 3D space during the Y-axis rotation.

Example 4 — Scene wrapper with perspective

Add perspective on an outer wrapper and preserve-3d on the inner object for a complete 3D setup.

scene.css
.scene {
  perspective: 800px;
}

.object {
  transform-style: preserve-3d;
  transform: rotateX(20deg) rotateY(-30deg);
}
Try It Yourself

How It Works

Perspective on the scene sets viewing distance; preserve-3d on the object keeps child transforms in true 3D space.

♿ Accessibility

  • Reduced motion — Disable or simplify 3D flip animations when prefers-reduced-motion: reduce is set.
  • Do not rely on 3D alone — Ensure content is readable without hover or rotation effects.
  • Avoid disorientation — Heavy 3D motion on large areas can distract or confuse users.
  • Keyboard access — Flippable cards should be operable without hover-only interaction.

The 3D transform stack

A working 3D effect usually combines perspective on an ancestor, transform-style: preserve-3d on the parent, and individual transform values on children.

3d-stack.css
.scene { perspective: 600px; }
.cube {
  transform-style: preserve-3d;
  transform: rotateX(45deg) rotateY(45deg);
}
.face { transform: translateZ(50px); }

🧠 How transform-style Works

1

Parent holds children

Child elements each get their own 3D transform.

Structure
2

transform-style is set

Choose flat to collapse or preserve-3d to keep depth.

Mode
3

Browser renders scene

With perspective, children appear at different depths in one 3D space.

Render
=

Cohesive 3D object

Faces and layers move together as a realistic 3D shape.

Browser Compatibility

The transform-style property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

Modern browsers · Widely supported

3D rendering in CSS

preserve-3d works in current Chrome, Firefox, Safari, Edge, and Opera for 3D cubes and flips.

97% Browser support
Google Chrome 36+ · Desktop & Mobile
Full support
Mozilla Firefox 16+ · Desktop & Mobile
Full support
Apple Safari 9+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 23+ · All versions
Full support

Testing tip

Test 3D flips and cubes on mobile Safari; stacking contexts from overflow: hidden can break preserve-3d.

transform-style property 97% supported

Bottom line: transform-style: preserve-3d is reliable for modern 3D CSS effects when paired with perspective.

Conclusion

The transform-style property is a powerful tool for web developers working with 3D transformations.

By controlling whether child elements are flattened or retain their 3D position, you can create complex and visually appealing 3D effects. Experiment with this property to see how it can enhance the depth and realism of your web designs.

💡 Best Practices

✅ Do

  • Use preserve-3d on the direct parent of 3D child faces
  • Add perspective on a wrapper for visible depth
  • Position faces with absolute and translateZ
  • Combine with backface-visibility: hidden on flip cards
  • Respect prefers-reduced-motion for animated 3D effects

❌ Don’t

  • Expect 3D depth with default flat on the parent
  • Forget perspective when building cubes or flips
  • Use overflow: hidden on parents if it breaks 3D rendering
  • Overuse heavy 3D animations on large page sections

Key Takeaways

Knowledge Unlocked

Five things to remember about transform-style

Use these points when building 3D CSS layouts.

5
Core concepts
02

flat

Default value.

Default
📚 03

preserve-3d

Keep 3D space.

Keyword
👁 04

perspective

Viewing depth.

Pair
📦 05

Cubes

6-face builds.

Pattern

❓ Frequently Asked Questions

transform-style controls whether child elements keep their 3D position or are flattened into the parent element's 2D plane.
The default is flat, which flattens children into the parent's plane so nested 3D transforms may not appear as expected.
Use preserve-3d on a parent when child elements need to form a true 3D scene, such as a cube, card flip, or layered 3D animation.
Yes for visible depth. Apply perspective on a parent (or use perspective() in a transform) so 3D child transforms look three-dimensional.
No, transform-style is not inherited. Set it on each element whose children should preserve 3D space.

Practice in the Live Editor

Open the HTML editor and build a 3D cube with transform-style: preserve-3d.

HTML Editor →

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.

5 people found this page helpful