CSS transition-property Property
The CSS transition-property property specifies which CSS properties should transition smoothly when their values change.
You can select an individual property, provide a comma-separated list of properties, allow all eligible properties to transition, or disable transitions. The property works with transition-duration, transition-timing-function, and transition-delay to control the complete transition effect.
transition-property Syntax
The transition-property property accepts all, none, or a comma-separated list of CSS property names.
Basic Syntax
.example {
transition-property: opacity;
}
All Properties
.example {
transition-property: all;
}
No Properties
.example {
transition-property: none;
}
Individual Property
.example {
transition-property: background-color;
}
Multiple Properties
.example {
transition-property: opacity, transform, background-color;
}
Custom Property
.example {
transition-property: --accent-color;
}
Custom properties can transition smoothly when registered with a suitable animatable syntax, such as <color>. Unregistered custom properties generally change discretely.
CSS-Wide Keywords
.example {
transition-property: initial;
}
.example {
transition-property: inherit;
}
.example {
transition-property: unset;
}
.example {
transition-property: revert;
}
.example {
transition-property: revert-layer;
}
Invalid Examples
.example {
transition-property: opacity transform;
}
.example {
transition-property: 0.5s;
}
.example {
transition-property: none, opacity;
}
Property names in a list must be separated by commas. Time values belong to other transition properties. The none keyword must appear by itself.
Property Values
| Value | Description |
|---|---|
all |
Selects all CSS properties eligible for transitions. This is the initial value. |
none |
Specifies that no CSS properties should transition. |
opacity |
Selects only the opacity property. |
transform |
Selects only the transform property. |
background-color |
Selects only the background-color property. |
opacity, transform |
Selects both opacity and transform. |
--custom-name |
Selects a named custom property. Smooth interpolation depends on its registration and animation type. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | all |
| Inherited | No |
| Applies to | All elements, including ::before and ::after |
| Computed value | As specified |
| Animation type | Not animatable |
| Percentages | Not accepted |
| Specification | CSS Transitions Level 1 |
Note: The transition-property property is a longhand component of the transition shorthand. Selecting a property does not guarantee that it will transition. Its values must change in a way supported by the property's animation type, and appropriate transition timing must be configured.
How It Works
CSS transitions compare an element's previous and new computed property values. The transition-property declaration determines which changes are eligible to produce transitions.
Step 1: Define the Initial Style
.button {
background-color: #2563eb;
color: #fff;
}
Step 2: Select the Property
.button {
transition-property: background-color;
}
Step 3: Add a Duration
.button {
transition-duration: 0.3s;
}
Step 4: Define the Changed State
.button:hover {
background-color: #1e40af;
color: #fef08a;
}
Complete Example
.button {
background-color: #2563eb;
color: #fff;
transition-property: background-color;
transition-duration: 0.3s;
transition-timing-function: ease;
}
.button:hover {
background-color: #1e40af;
color: #fef08a;
}
Understanding the Result
The background color transitions over 0.3 seconds because it is selected by transition-property. The text color changes immediately because it is not included in the transition property list.
Important Consideration
By default, transition-duration is 0s. Setting transition-property alone does not produce a visible gradual transition.
The all Value
The all keyword selects every CSS property that is eligible to transition when its value changes.
Basic Example
.example {
transition-property: all;
transition-duration: 0.3s;
}
Using the Shorthand
.example {
transition: all 0.3s ease;
}
Multiple Property Changes
.card {
background-color: #f3f4f6;
color: #111827;
transform: scale(1);
transition: all 0.3s ease;
}
.card:hover {
background-color: #dbeafe;
color: #1e40af;
transform: scale(1.03);
}
The background color, text color, and transform can all transition because they are eligible properties.
Advantages
The all keyword is convenient for simple demonstrations and components where several properties intentionally share the same transition settings.
Potential Drawbacks
Using all can unintentionally transition properties added later. Some properties, including layout-related properties, may require additional rendering work during a transition.
Recommended Alternative
.card {
transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
}
Explicit property names make it easier to understand and maintain the intended effects.
The none Value
The none keyword prevents CSS transitions from being generated for the element.
Basic Example
.example {
transition-property: none;
}
Disabling an Existing Transition
.button {
transition: background-color 0.3s ease;
}
.button.no-transition {
transition-property: none;
}
Using the Shorthand
.example {
transition: none;
}
The shorthand sets transition-property to none and resets the other transition longhand properties to their initial values.
Reduced Motion
@media (prefers-reduced-motion: reduce) {
.animated-element {
transition-property: none;
}
}
Invalid Combination
.example {
transition-property: none, opacity;
}
The none keyword cannot be combined with property names in a transition property list.
Important Consideration
The none value disables CSS transitions, not CSS animations created using @keyframes. Animations must be controlled separately.
Individual Property Names
Specifying an individual CSS property limits transitions to that property.
Opacity
.example {
transition-property: opacity;
transition-duration: 0.3s;
}
Transform
.example {
transition-property: transform;
transition-duration: 0.4s;
}
Background Color
.example {
transition-property: background-color;
transition-duration: 0.2s;
}
Width
.example {
transition-property: width;
transition-duration: 0.5s;
}
Width can transition between compatible values, but changing it may cause layout recalculation.
Border Radius
.example {
transition-property: border-radius;
transition-duration: 0.3s;
}
Box Shadow
.example {
transition-property: box-shadow;
transition-duration: 0.3s;
}
Selecting a Shorthand Property
.example {
transition-property: margin;
transition-duration: 0.3s;
}
When a shorthand property is selected, its corresponding longhand properties are considered for transitions. The individual longhands must still have compatible, transitionable value changes.
Recommended Practice
Prefer explicit property names when possible. For movement and scaling effects, transform is often preferable to animating layout-related properties such as left, top, or width.
Multiple Transition Properties
Use a comma-separated list to select multiple properties for transitions.
Two Properties
.example {
transition-property: opacity, transform;
transition-duration: 0.3s;
}
Three Properties
.example {
transition-property: opacity, transform, background-color;
transition-duration: 0.3s;
}
Different Durations
.example {
transition-property: opacity, transform;
transition-duration: 0.2s, 0.5s;
}
Opacity transitions over 0.2 seconds, while transform transitions over 0.5 seconds.
Different Delays
.example {
transition-property: opacity, transform;
transition-duration: 0.3s;
transition-delay: 0s, 0.2s;
}
Different Timing Functions
.example {
transition-property: opacity, transform;
transition-duration: 0.3s, 0.5s;
transition-timing-function: linear, ease-out;
}
Complete Example
.card {
opacity: 0.8;
transform: translateY(0);
background-color: #f3f4f6;
transition-property: opacity, transform, background-color;
transition-duration: 0.2s, 0.4s, 0.3s;
transition-timing-function: linear, ease-out, ease;
}
.card:hover {
opacity: 1;
transform: translateY(-5px);
background-color: #dbeafe;
}
Important Consideration
Each selected property is matched with the corresponding transition timing values. Keep lists in a consistent order to avoid unexpected results.
Animatable and Discrete Properties
Not every CSS property can interpolate smoothly between values. The property's animation type determines how its values can change during a transition.
Interpolated Properties
Properties such as opacity, color, background-color, and transform can transition smoothly between compatible values.
.example {
transition-property: opacity, transform;
transition-duration: 0.3s;
}
Discrete Properties
Discrete properties switch between values rather than interpolating continuously. Examples include display and visibility, although their transition behavior differs.
Using transition-behavior
.panel {
transition-property: opacity, display;
transition-duration: 0.3s;
transition-behavior: allow-discrete;
}
The allow-discrete value permits eligible discrete properties to participate in transitions. The browser determines the appropriate switching point for each property.
Visibility Transitions
.panel {
opacity: 1;
visibility: visible;
transition: opacity 0.3s ease, visibility 0.3s;
}
.panel.is-hidden {
opacity: 0;
visibility: hidden;
}
The opacity interpolates smoothly, while visibility changes discretely. Visibility has special transition behavior that keeps the element visible during the opacity transition.
Custom Properties
@property --accent-color {
syntax: "<color>";
inherits: false;
initial-value: #2563eb;
}
.example {
background-color: var(--accent-color);
transition-property: --accent-color;
transition-duration: 0.4s;
}
.example:hover {
--accent-color: #dc2626;
}
Registering the custom property with a color syntax allows its color values to interpolate.
Important Consideration
Adding a property name to transition-property does not automatically make it smoothly animatable. Check the property's animation type and browser support.
Using the transition Shorthand
The transition-property property is included in the transition shorthand.
Longhand Syntax
.example {
transition-property: opacity;
transition-duration: 0.5s;
transition-timing-function: ease;
transition-delay: 0.2s;
}
Equivalent Shorthand
.example {
transition: opacity 0.5s ease 0.2s;
}
Multiple Properties
.example {
transition: opacity 0.3s ease, transform 0.5s ease-out;
}
Using all
.example {
transition: all 0.3s ease;
}
Using none
.example {
transition: none;
}
Omitting the Property Name
.example {
transition: 0.3s ease;
}
When the property name is omitted, the shorthand uses all.
Shorthand Reset Behavior
.example {
transition-property: opacity;
transition: transform 0.3s ease;
}
The shorthand replaces the previous property selection with transform.
Correct Declaration Order
.example {
transition: all 0.3s ease;
transition-property: opacity;
}
The later longhand declaration restricts the transition to opacity.
Matching Transition Values
CSS matches the entries in transition-property with the corresponding values in the other transition longhand lists.
Matching Two Properties
.example {
transition-property: opacity, transform;
transition-duration: 0.2s, 0.5s;
transition-delay: 0s, 0.1s;
}
| Property | Duration | Delay |
|---|---|---|
opacity |
0.2s |
0s |
transform |
0.5s |
0.1s |
Repeating Shorter Lists
.example {
transition-property: opacity, transform, background-color;
transition-duration: 0.2s, 0.5s;
}
The duration list repeats as necessary. Opacity uses 0.2 seconds, transform uses 0.5 seconds, and background color uses 0.2 seconds.
Extra Timing Values
.example {
transition-property: opacity, transform;
transition-duration: 0.2s, 0.5s, 1s;
}
The third duration does not create an additional transition because only two transition properties are selected.
Duplicate Property Names
.example {
transition-property: opacity, opacity;
transition-duration: 0.2s, 0.6s;
}
If the same property appears more than once, the last matching entry determines its transition settings. In this example, opacity uses the 0.6-second duration.
Overlapping all and Named Properties
.example {
transition-property: all, opacity;
transition-duration: 0.3s, 0.6s;
}
The final matching entry for opacity uses 0.6 seconds. Other eligible properties use the settings associated with all.
Recommended Practice
Avoid duplicate or overlapping transition property entries unless they are intentional. Explicit, nonoverlapping lists are easier to maintain.
Related CSS Properties
The transition-property property works with the other CSS transition longhand properties.
transition
.example {
transition: opacity 0.3s ease;
}
Combines transition settings into a shorthand declaration.
transition-duration
.example {
transition-duration: 0.3s;
}
Specifies how long each transition takes.
transition-delay
.example {
transition-delay: 0.2s;
}
Specifies how long the browser waits before starting a transition.
transition-timing-function
.example {
transition-timing-function: ease-in-out;
}
Controls the rate of progress during the transition.
transition-behavior
.example {
transition-behavior: allow-discrete;
}
Allows eligible discrete properties to participate in transitions.
Complete Example
.example {
transition-property: opacity, transform;
transition-duration: 0.3s, 0.5s;
transition-timing-function: ease, ease-out;
transition-delay: 0s, 0.1s;
transition-behavior: normal;
}
Inheritance
The transition-property property is not inherited. Child elements do not automatically use their parent's transition property list.
Parent Element
.parent {
transition-property: opacity;
}
Child Element
.child {
transition-property: transform;
}
Explicit Inheritance
.child {
transition-property: inherit;
}
Restore the Initial Value
.child {
transition-property: initial;
}
This restores the initial value of all.
Using unset
.child {
transition-property: unset;
}
Because the property is not inherited, unset restores its initial value.
Important Consideration
Declare transition properties on the elements whose visual changes should transition.
Practical Examples
Button Background Color
.button {
background-color: #2563eb;
transition-property: background-color;
transition-duration: 0.2s;
}
.button:hover {
background-color: #1e40af;
}
Card Movement
.card {
transform: translateY(0);
transition-property: transform;
transition-duration: 0.3s;
}
.card:hover {
transform: translateY(-5px);
}
Image Opacity
.image {
opacity: 0.7;
transition-property: opacity;
transition-duration: 0.4s;
}
.image:hover {
opacity: 1;
}
Input Border Color
.input {
border: 2px solid #9ca3af;
transition-property: border-color;
transition-duration: 0.2s;
}
.input:focus-visible {
border-color: #2563eb;
}
Multiple Card Effects
.card {
opacity: 0.8;
transform: scale(1);
transition-property: opacity, transform;
transition-duration: 0.2s, 0.4s;
}
.card:hover {
opacity: 1;
transform: scale(1.03);
}
Navigation Link Color
.nav-link {
color: #374151;
transition-property: color;
transition-duration: 0.2s;
}
.nav-link:hover,
.nav-link:focus-visible {
color: #2563eb;
}
Disable Transitions for Reduced Motion
@media (prefers-reduced-motion: reduce) {
.animated-element {
transition-property: none;
}
}
transition-property Example
This example compares three buttons with different transition property selections. Hover over or keyboard-focus each button to see which changes occur smoothly.
HTML Example
<div class="property-demo">
<button class="property-button property-color" type="button">Color Only</button>
<button class="property-button property-transform" type="button">Transform Only</button>
<button class="property-button property-both" type="button">Both Properties</button>
</div>
CSS Example
.property-demo {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 20px;
padding: 20px;
}
.property-button {
min-width: 140px;
padding: 12px 18px;
border: 0;
border-radius: 4px;
background-color: #2563eb;
color: #fff;
font: inherit;
cursor: pointer;
transform: translateY(0);
transition-duration: 0.6s;
transition-timing-function: ease;
}
.property-button:hover,
.property-button:focus-visible {
background-color: #1e40af;
transform: translateY(-5px);
}
.property-button:focus-visible {
outline: 3px solid #f59e0b;
outline-offset: 3px;
}
.property-color {
transition-property: background-color;
}
.property-transform {
transition-property: transform;
}
.property-both {
transition-property: background-color, transform;
}
@media (prefers-reduced-motion: reduce) {
.property-button {
transition: none;
}
}
Understanding the Results
All three buttons change background color and position when hovered or focused. Their transition property selections determine which changes happen gradually.
Color Only
The background color transitions smoothly over 0.6 seconds. The position changes immediately.
Transform Only
The position transitions smoothly over 0.6 seconds. The background color changes immediately.
Both Properties
Both the background color and position transition smoothly over 0.6 seconds.
Experiment With all
.property-color {
transition-property: all;
}
Both eligible property changes now transition because all includes background color and transform.
Experiment With none
.property-transform {
transition-property: none;
}
Both property changes occur without gradual transitions.
Experiment With Different Durations
.property-both {
transition-property: background-color, transform;
transition-duration: 0.2s, 1s;
}
The background color changes over 0.2 seconds, while the transform takes one second.
Accessibility Considerations
CSS transitions should improve visual feedback without interfering with usability or user preferences.
Respect Reduced Motion Preferences
@media (prefers-reduced-motion: reduce) {
.interactive-element {
transition: none;
}
}
Maintain Visible Focus Indicators
Keyboard focus indicators should appear promptly and remain clearly visible. Avoid transitions that make focus difficult to identify.
Avoid Unnecessary Motion
Use movement and scaling effects only when they provide useful feedback. Avoid excessive or distracting motion.
Preserve Readability
Ensure that transitioning colors maintain adequate contrast throughout the effect whenever text remains visible.
Support Multiple Input Methods
Do not rely exclusively on hover effects. Provide appropriate feedback for keyboard and touch interaction.
Avoid Delaying Essential Information
Transitions should not prevent users from accessing important content or controls.
Keep State Changes Understandable
The interface should remain clear when transitions are disabled or unsupported.
Common Mistakes
Forgetting the Transition Duration
.example {
transition-property: opacity;
}
The initial duration is 0s, so the property change does not interpolate gradually.
Forgetting Commas
.example {
transition-property: opacity transform;
}
Separate multiple property names with commas.
Combining none With Other Values
.example {
transition-property: none, opacity;
}
The none keyword must appear by itself.
Using Time Values
.example {
transition-property: 0.3s;
}
Time values belong to transition-duration or transition-delay.
Expecting Every Property to Interpolate
Some properties are discrete or cannot transition. Selecting them does not automatically create smooth interpolation.
Using all Unnecessarily
The all keyword can cause unintended transitions when additional CSS properties change.
Overwriting the Property List With Shorthand
.example {
transition-property: opacity;
transition: transform 0.3s ease;
}
The shorthand replaces the previous property selection with transform.
Mismatching Transition Lists
Different list lengths are allowed, but repeated timing values may produce unexpected results if the order is not understood.
Animating Layout Properties Unnecessarily
Transitions involving width, height, and positioning can cause layout recalculation. Consider transforms for visual movement when appropriate.
Ignoring Reduced Motion Preferences
Provide alternatives for users who prefer reduced motion.
Important Considerations
Keep the following points in mind when using transition-property:
- The property specifies which CSS properties are eligible to transition.
- The initial value is
all. - The property is not inherited.
- The
allkeyword selects all eligible properties. - The
nonekeyword disables CSS transitions. - The
nonekeyword cannot be combined with property names. - Individual CSS property names can be selected.
- Multiple properties must be separated by commas.
- Property names are matched with corresponding transition timing values.
- Shorter timing lists repeat values as needed.
- Extra timing values do not create additional transitions.
- Duplicate property names use the last matching transition definition.
- The property is a longhand component of
transition. - Shorthand declarations can reset earlier property selections.
- Omitting the property name in the shorthand selects
all. - A nonzero duration is normally required for visible gradual interpolation.
- Eligible property values must change to trigger a transition.
- Not every CSS property supports smooth interpolation.
- Eligible discrete properties may require
transition-behavior: allow-discrete. - Registered custom properties can support smooth transitions when their syntax permits interpolation.
- Using
allmay cause unintended transitions. - Explicit property names make transition behavior easier to maintain.
- Transitions involving layout properties may affect rendering performance.
- Transitions can be interrupted or reversed.
- Respect reduced motion preferences.
- Test transition behavior across supported browsers.
Browser Support
The CSS transition-property property is widely supported across modern browsers. The all and none keywords, individual property names, and comma-separated property lists are part of the established CSS Transitions feature set.
Support for transitions involving newer discrete properties and registered custom properties can vary. Check the compatibility of those related features separately.
For current compatibility information, visit Can I Use? and search for transition-property.
Basic Declaration
.example {
transition-property: opacity;
}
Multiple Properties
.example {
transition-property: opacity, transform;
}
Feature Detection
@supports (transition-property: opacity) {
.example {
transition-property: opacity;
transition-duration: 0.3s;
}
}
Testing Recommendations
Test individual property transitions, multiple transition lists, interrupted transitions, and reduced motion settings. For discrete properties and registered custom properties, verify the specific browser support required by your implementation.
Specifications
The transition-property property is defined in the CSS Transitions Level 1 specification.
CSS Transitions Level 1 - The transition-property Property
The specification defines valid property selections, the all and none keywords, and how transition property lists correspond to timing values.
For additional documentation and examples, consult MDN Web Docs.
