In this section, we will learn what the backface-visibility property is and how to use it in CSS.
CSS backface-visibility Property Definition and Usage
By default, when we rotate an element in Y or X axes using `rotateY`/ `rotateX` functions and `transform` property, the back-face of the target element will be visible if the rotation passed 90 degrees.
But CSS provides a property named `backface-visibility` by which we can decide whether to show the back-face of the target element or not!
CSS backface-visibility Property Syntax
CSS backface-visibility Property Value
There are two values that can be used for this property:
- visible: this is the default value and when used, the back-face of the target element will be shown to users when rotation passed 90 degrees.
- hidden: Using this value, the back-face of the target element becomes hidden from users when the rotation passed 90 degrees.
Example: backface-visibility property in CSS
How Does CSS backface-visibility Property Work?
In the example above, the first paragraph has the default value of visible, so even though we rotate that element, it is still visible to users. But the second paragraph is not visible because of the value “hidden” set for its `backface-visibility` property.
One possible application of this technique is to place two elements back-to-back, like two sides of a card. The front of the card will be visible, but the back of the card is hidden. Then we can flip both elements around, making the front hidden and the back visible.