A name still needs a duration
.label {
animation-name: fade-in;
animation-duration: 0.4s;
animation-timing-function: ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }The animation uses the default ease timing and a single iteration. The 0.4s duration is required; the initial duration is 0s.
- from and to are the 0% and 100% keyframes. The parser records both.
<p class="label">Status</p>
<style>
.label { font-family: sans-serif; color: #0B5853; animation-name: fade-in; animation-duration: 0.4s; animation-timing-function: ease; }
@keyframes fade-in {
from { opacity: 0; }
to { opacity: 1; }
}
</style>What this markup means
animation-name: fade-in is not enough on its own: animation-duration: 0.4s overrides the initial 0s so the fade can run. animation-timing-function: ease matches the initial value and is written here to make that default visible. There is no fill-mode in this rule, so it stays at the initial none: after the 0.4s the animation’s effect ends and the element’s underlying styles apply again. For decorative fades, also provide a prefers-reduced-motion alternative on the media queries page.
Related: Media queries (reduced motion), Transitions