For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/css/properties/animation-fill-mode.md.
Lynx
  • English
  • animation-fill-mode

    Introduction

    animation-fill-mode property sets how a CSS animation applies styles to its target before and after its execution.

    Examples

    Syntax

    /* Single animation */
    animation-fill-mode: none;
    animation-fill-mode: forwards;
    animation-fill-mode: backwards;
    animation-fill-mode: both;
    
    /* Multiple animations */
    animation-fill-mode: none, backwards;
    animation-fill-mode: both, forwards, none;

    Values

    none

    Default value. The animation will not apply any styles to the target when it's not executing. The element will display using the CSS rules that have already been applied to it. This is the default value.

    forwards

    The target will retain the computed values set by the last keyframe encountered during execution. The last keyframe depends on the values of animation-direction and animation-iteration-count:

    animation-directionanimation-iteration-countlast keyframe encountered
    normaleven or odd100% or to
    reverseeven or odd0% or from
    alternateeven0% or from
    alternateodd100% or to
    alternate-reverseeven100% or to
    alternate-reverseodd0% or from

    backwards

    The animation will apply the values defined in the first keyframe at the start of the animation. The first keyframe depends on the value of animation-direction:

    animation-directionfirst relevant keyframe
    normal or alternate0% or from
    reverse or alternate-reverse100% or to

    both

    The animation will follow both the forwards and backwards rules, applying the keyframe values both before and after the animation.

    Formal definition

    Initial valuenone
    Applies toall elements
    Inheritedno
    Animatableno

    Formal syntax

    /*none*/
    animation-fill-mode: none | forwards | backwards | both;

    See also

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.