--- id: css-animation-properties title: "CSS Animation Properties" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["animation-direction", "animation-fill-mode", "animation shorthand", "animation-play-state", "alternate", "forwards"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "animation", "shorthand", "fill-mode"] raw_sources: ["https://www.w3schools.com/css/css3_animations_properties.asp"] applied_in: [] github_commit: "" --- # [[CSS Animation Properties]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `animation-direction` controls forward/backward/alternating playback, `animation-fill-mode` controls the element's style when the animation is not playing, and the `animation` shorthand packs all the individual animation properties into one declaration. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`animation-direction`** β€” specifies whether an animation should be played forwards, backwards, or in alternate cycles. [S1] - **`animation-fill-mode`** β€” specifies a style for the target element when the animation is not playing (before it starts, after it ends, or both). [S1] - **`animation` shorthand** β€” sets all the animation properties in a single declaration. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Playback direction** β€” choose `normal`, `reverse`, `alternate`, or `alternate-reverse` (alternation needs an iteration count > 1 to be visible). [S1] - **Persisting end/start state** β€” use `animation-fill-mode: forwards` to keep the last keyframe's style, `backwards` for the first keyframe during delay, or `both`. [S1] - **Shorthand ordering** β€” `animation: name duration timing-function delay iteration-count direction;`. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **The `animation-direction` Property** The `animation-direction` property specifies whether an animation should be played forwards, backwards or in alternate cycles. The `animation-direction` property can have the following values: [S1] - `normal` β€” the animation is played as normal (forwards). This is default. [S1] - `reverse` β€” the animation is played in reverse direction (backwards). [S1] - `alternate` β€” the animation is played forwards first, then backwards. [S1] - `alternate-reverse` β€” the animation is played backwards first, then forwards. [S1] The following example will run the animation in reverse direction (backwards): [S1] ```css div { width: 100px; height: 100px; position: relative; background-color: red; animation-name: myAnimation; animation-duration: 4s; animation-direction: reverse; } ``` The following example uses the value "alternate" to make the animation run forwards first, then backwards: [S1] ```css div { width: 100px; height: 100px; position: relative; background-color: red; animation-name: myAnimation; animation-duration: 4s; animation-iteration-count: 2; animation-direction: alternate; } ``` The following example uses the value "alternate-reverse" to make the animation run backwards first, then forwards: [S1] ```css div { width: 100px; height: 100px; position: relative; background-color: red; animation-name: myAnimation; animation-duration: 4s; animation-iteration-count: 2; animation-direction: alternate-reverse; } ``` **The `animation-fill-mode` Property** The `animation-fill-mode` property specifies a style for the target element when the animation is not playing (before it starts, after it ends, or both). The `animation-fill-mode` property can have the following values: [S1] - `none` β€” default value. Animation will not apply any styles to the element before or after it is executing. [S1] - `forwards` β€” the element will retain the style values that are set by the last keyframe (depends on animation-direction and animation-iteration-count). [S1] - `backwards` β€” the element will get the style values that are set by the first keyframe (depends on animation-direction), and retain this during the animation-delay period. [S1] - `both` β€” the animation will follow the rules for both forwards and backwards, extending the animation properties in both directions. [S1] The following example lets the `
` element retain the style values from the last keyframe when the animation ends: [S1] ```css div { width: 100px; height: 100px; background: red; position: relative; animation-name: myAnimation; animation-duration: 3s; animation-fill-mode: forwards; } ``` The following example lets the `
` element get the style values set by the first keyframe before the animation starts (during the animation-delay period): [S1] ```css div { width: 100px; height: 100px; background: red; position: relative; animation-name: myAnimation; animation-duration: 3s; animation-delay: 2s; animation-fill-mode: backwards; } ``` The following example lets the `
` element get the style values set by the first keyframe before the animation starts, and retain the style values from the last keyframe when the animation ends: [S1] ```css div { width: 100px; height: 100px; background: red; position: relative; animation-name: myAnimation; animation-duration: 3s; animation-delay: 2s; animation-fill-mode: both; } ``` **Animation Shorthand Property** The animation properties can be specified one by one, like this: [S1] ```css div { animation-name: myAnimation; animation-duration: 5s; animation-timing-function: linear; animation-delay: 2s; animation-iteration-count: infinite; animation-direction: alternate; } ``` The same animation effect as above can be achieved by using the shorthand `animation` property: [S1] ```css div { animation: myAnimation 5s linear 2s infinite alternate; } ``` **CSS Animation Properties** The following table lists the `@keyframes` rule and all the CSS animation properties: [S1] | Property | Description | |----------|-------------| | `@keyframes` | Specifies the animation code | | `animation` | A shorthand property for setting all the animation properties | | `animation-delay` | Specifies a delay for the start of an animation | | `animation-direction` | Specifies whether an animation should be played forwards, backwards or in alternate cycles | | `animation-duration` | Specifies how long time an animation should take to complete one cycle | | `animation-fill-mode` | Specifies a style for the element when the animation is not playing (before it starts, after it ends, or both) | | `animation-iteration-count` | Specifies the number of times an animation should be played | | `animation-name` | Specifies the name of the @keyframes animation | | `animation-play-state` | Specifies whether the animation is running or paused | | `animation-timing-function` | Specifies the speed curve of the animation | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page applies `reverse`, `alternate`, and `alternate-reverse` directions to a `
`, the `forwards`/`backwards`/`both` fill modes, and shows the same animation expressed both as individual properties and as the `animation` shorthand (`myAnimation 5s linear 2s infinite alternate`). No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Individual properties vs. shorthand (language: CSS): ```css div { animation-name: myAnimation; animation-duration: 5s; animation-timing-function: linear; animation-delay: 2s; animation-iteration-count: infinite; animation-direction: alternate; } div { animation: myAnimation 5s linear 2s infinite alternate; } ``` Fill mode to retain end state: ```css div { animation-fill-mode: forwards; } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) For `animation-direction`, pick `normal` for plain forward playback, `reverse` to run backwards, `alternate` to bounce forward-then-back, and `alternate-reverse` to bounce back-then-forward (the alternating options require an iteration count above 1). For `animation-fill-mode`, use `forwards` to keep the final keyframe's appearance after the animation ends, `backwards` to apply the first keyframe during the delay, `both` for both effects, and `none` (default) to apply no styles outside the active run. The `animation` shorthand is preferred for conciseness when several properties are set together. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Animations]], [[CSS Animation Timing]], [[CSS Transition Timing]] - **μ°Έμ‘° λ§₯락:** Completes the animation feature set with direction, fill-mode, and the shorthand that consolidates all animation properties. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Animation Properties β€” https://www.w3schools.com/css/css3_animations_properties.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Animation Properties" page (Astra wiki-curation, P-Reinforce v3.1 format).