backface-visibility

Avatar of Sara Cope
Sara Cope on (Updated on )

Learn Development at Frontend Masters

The backface-visibility property relates to 3D transforms. With 3D transforms, you can manage to rotate an element so what we think of as the “front” of an element no longer faces the screen. For instance, this would flip an element away from the screen:

.flip {
  transform: rotateY(180deg);
}

It will look as if you picked it up with a spatula and flipped it over like a pancake. That’s because the default for backface-visibility is visible. Instead of it being visible, you could hide it.

.flip {
  transform: rotateY(180deg);
  backface-visibility: hidden;
}

Syntax

backface-visibility: visible | hidden;
  • Initial value: visible
  • Applies to: transformable elements
  • Inherited: no
  • Percentages: n/a
  • Computed value: specific keyword
  • Animation type: discrete

Values

  • visible (default) – The element will always be visible even when not facing the screen.
  • hidden – The element is not visible when not facing the screen.
  • inherit – The property gets its value from the its parent element.
  • initial – Sets the property to its default, which is visible.

Demo

This is useful when doing 3D effects. For instance…

Works properly

<div class="container">
<div class="card">
<div class="face front">Front</div>
<div class="face back">Back</div>
<p> </p>
</div>
</div>

Problematic in WebKit because backface-visibility not hidden

<div class="container no-hide">
<div class="card">
<div class="face front">Front</div>
<div class="face back">Back</div>
<p> </p>
</div>
</div>

This isn’t problematic in Firefox for whatever reason, although the property works the same way.

Browser support

IEEdgeFirefoxChromeSafariOpera
10All10 112 25.1 215 2
Android ChromeAndroid FirefoxAndroid BrowseriOS SafariOpera Mobile
AllAll3 25 262
Source: caniuse

1 Supported in Firefox 10-15 with prefix -moz-
2 Supported in Chrome 12-35, Safari, Safari iOS, and Opera 15-22 with prefix -webkit-