---
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).