Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

Should I transition all CSS properties or name only the ones that change?

Quick answer

Name the properties you intend to animate in most cases. An explicit list makes the effect easier to understand and prevents unrelated property changes from joining the transition. Use all only when you deliberately want every changed property that can transition to receive the same treatment. Neither choice is automatically faster: performance depends on which properties actually change and the rendered workload.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

Should I transition all CSS properties or name only the ones that change?

Geez

Usually, name the properties you intend to animate. For example, if a button changes its background and slightly grows when hovered, write transition: background-color 180ms ease, transform 180ms ease; rather than transition: all 180ms ease;.

An explicit list communicates which changes are part of the interaction. With all, any changed property that can transition may get the same transition, including a property someone adds later for another reason. MDN describes all as applying to all properties that change state, while an explicit list limits the transition to named properties. [S1]

There are situations where all is convenient, such as a small component whose changed properties are intentionally treated alike. But convenience is not a reason to assume every future style change should animate.

Follow-up question

What does an unintended transition look like in practice?

Geez

Suppose a card has a hover effect for transform and box-shadow. Later, someone adds a width change to a state that also affects the card. If the base rule says transition: all 200ms ease, that width change may animate too, even though it was not part of the original hover design. An explicit list keeps the transition tied to the intended effects:

.card {
  transition: transform 200ms ease, box-shadow 200ms ease;
}

The practical point is that naming properties makes the intended behavior clearer and reduces surprises when styles evolve. [S1] For a quick review, compare the properties in the resting and interactive states. If a property changes but should change immediately, leave it out.

Follow-up question

Is using all inherently slower? Should performance decide this?

Geez

No. all is not inherently slow just because the word appears in the declaration. What matters is which properties actually change and what work those changes cause in the rendered page. MDN notes that changes to dimensions, borders, padding, positioning, and other layout-related properties can trigger reflow and repaint, while transforms and opacity are among properties that can avoid those costs. [S2]

So, prefer an explicit list for control, then inspect the properties in that list. Don’t treat transform or opacity as a guarantee of smoothness in every workload, or treat all as proof of a performance problem. Performance on a particular page depends on its actual rendering workload. [S2]

Follow-up question

How should I decide what to put in the list when I edit a component?

Geez

Start with the component’s states, such as its normal and hover states. List only the properties whose change is meant to animate, then choose timing for each. For example, if color should move gently but a small scale change should finish sooner, give the properties separate durations:

.button {
  transition: background-color 220ms ease, transform 140ms ease;
}

MDN supports explicit property lists with per-property timing. It also notes that a later named transition can override an earlier all entry for that property. [S1] That override can be useful, but a direct list is often easier to maintain: readers can see the intended animations without working out which declaration takes precedence.

A reusable rule: use all only when you can explain why every changed, transitionable property should share the effect. Otherwise, name the properties. After editing, compare the relevant states and check that each listed property is intentional. If a property is added later, decide explicitly whether it belongs in the animation.

A practical checklist

  • Compare the component’s resting and interactive states.

  • Write down only the properties intended to animate.

  • Use an explicit property list unless every changed property should share the transition.

  • Give properties separate timing when their intended effects differ.

  • Review layout-related properties deliberately; rendering cost depends on the actual workload.

  • After a style change, check that no newly changed property animates by accident.

A few more useful answers

Can I combine `all` with a named property?

Yes. MDN notes that a later named transition can override an earlier all entry for that property. Still, an explicit list may be easier to read when you want only selected properties to animate. [S1]

Does naming properties guarantee better animation performance?

No. Naming helps control which properties transition, but it does not by itself establish rendering performance. The properties that change and the page’s workload matter. [S2]

What if I cannot tell whether a property should animate?

Compare the component before and after the state change. If animating that difference is not an intentional part of the interaction, leave it out of the transition list and check the result in context.

Sources

References used for this guide.

  1. [S1] MDN: transition CSS property
    developer.mozilla.org · Checked
  2. [S2] MDN: CSS performance optimization and animated properties
    developer.mozilla.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work