The transition-property Property
You'll learn how to tell the browser exactly which CSS properties should smoothly animate when their values change.
What Is transition-property?
In the previous lesson, you learned that CSS transitions create smooth animations when property values change. But what if you only want some properties to animate, not all of them? That's where transition-property comes in.
The transition-property property lets you specify which CSS properties should transition. Think of it like setting up a guest list for a party—you're explicitly saying who's invited to the animation.
The Syntax
.box {
transition-property: background-color;
}
This tells the browser: "Only animate background-color when it changes. Everything else changes instantly."
Common Values
You can use several values with transition-property:
- Specific property names:
opacity,transform,color, etc. - Multiple properties (comma-separated):
background-color, opacity, transform all(the default): Animates every animatable property that changesnone: Disables all transitions
.card {
/* Only animate these two properties */
transition-property: opacity, transform;
}
.button {
/* Animate everything that changes */
transition-property: all;
}
Why Be Specific?
Sometimes you want instant changes for some properties and smooth transitions for others. For example, you might want color to change immediately while opacity fades smoothly. Using transition-property gives you that control.
Key Takeaway: The transition-property property controls which CSS properties will animate when they change, letting you create selective, intentional transitions instead of animating everything.