Color and opacity can interpolate when a duration is set
.fade { color: #0B5853; opacity: 1; transition: color 0.2s ease, opacity 0.2s ease; }
.fade:hover { color: #1A1A1A; opacity: 0.7; }Two interpolable properties share a 0.2s ease transition. The initial duration is 0s, so the duration has to be written.
- The :hover rule is only a change trigger in the stylesheet. This is not a pointer or timing measurement.
<button class="fade" type="button">Save</button>
<style>
.fade { font-family: sans-serif; color: #0B5853; background: #F3EFE4; border: 1px solid #0B5853; opacity: 1; transition: color 0.2s ease, opacity 0.2s ease; }
.fade:hover { color: #1A1A1A; opacity: 0.7; }
</style>What this markup means
transition lists color and opacity, each with a 0.2s ease duration. Both properties interpolate between specified values: two colors, and two numbers in 0–1. The button remains in the document. If the duration were omitted, the initial 0s would apply and the same property changes would snap. prefers-reduced-motion, on the media queries page, is the place to turn decorative motion off.