CSS propertyTransforms

backface-visibility

Decides whether the back of an element rotated in 3D is visible.

Initial value
visible
Inherited
No
Animatable
no
Applies to
transformable elements
JavaScript
element.style.backfaceVisibility = "hidden"
On this page

Example

#
CSS
.card { transform-style: preserve-3d; transition: transform 0.6s; }
.card.flipped { transform: rotateY(180deg); }
.face { backface-visibility: hidden; position: absolute; inset: 0; }
.back { transform: rotateY(180deg); }
Preview

Definition and usage

#

When you rotate an element by more than 90 degrees around the X or Y axis, you see its back, which is a mirror image of the front. The backface-visibility: hidden property hides that back.

This is the basis of the card flip effect: two layers, front and back, stacked on top of each other. The back is pre-rotated by 180 degrees, and both sides have their reverse hidden. After rotating the whole card, you see one side or the other.

The property only works in a 3D context, usually with transform-style: preserve-3d on the parent.

Syntax

#
Syntax
backface-visibility: visible | hidden;

Values

#
  • visible

    After rotation you see the mirrored text.
  • hidden

    The back is invisible, so the rotated element disappears.

Values in practice

#

visible

After rotation you see the mirrored text.
.demo { backface-visibility: visible; }

hidden

The back is invisible, so the rotated element disappears.
.demo { backface-visibility: hidden; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • For flip cards you need three things: perspective on the container, preserve-3d on the card, and backface-visibility: hidden on the faces.
  • Older Safari versions required the -webkit-backface-visibility prefix.

Related entries

#

Practise it in lessons

#

Spotted a mistake or missing an example? Write to us.