--- id: css-animation-timing title: "CSS Animation Timing" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["animation-delay", "animation-iteration-count", "animation-timing-function", "infinite animation", "negative delay", "animation speed curve"] 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", "timing-function", "iteration"] raw_sources: ["https://www.w3schools.com/css/css3_animations_timing.asp"] applied_in: [] github_commit: "" --- # [[CSS Animation Timing]] ## π― ν μ€ ν΅μ°° (One-line insight) Animation timing controls when and how often an animation runs: `animation-delay` postpones (and, when negative, fast-forwards) the start, `animation-iteration-count` sets how many times it repeats (including `infinite`), and `animation-timing-function` sets the speed curve. [S1] ## π§ ν΅μ¬ κ°λ (Core concepts) - **`animation-delay`** β specifies a delay for the start of an animation; negative values make the animation start as if it had already been playing for that many seconds. [S1] - **`animation-iteration-count`** β specifies the number of times an animation should run; accepts a number or the keyword `infinite`. [S1] - **`animation-timing-function`** β specifies the speed curve of the animation. [S1] ## π§© μΆμΆλ ν¨ν΄ (Extracted patterns) - **Negative delay = head start** β a negative `animation-delay` begins partway through the animation. [S1] - **Loop forever** β `animation-iteration-count: infinite;` repeats the animation endlessly. [S1] - **Speed-curve selection** β same value set as transitions: `ease` (default), `linear`, `ease-in`, `ease-out`, `ease-in-out`, `cubic-bezier(n,n,n,n)`. [S1] ## π μΈλΆ λ΄μ© (Details) **Delay an Animation** The `animation-delay` property specifies a delay for the start of an animation. The following example has a 2 seconds delay before starting the animation: [S1] ```css div { width: 100px; height: 100px; position: relative; background-color: red; animation-name: myAnimation; animation-duration: 4s; animation-delay: 2s; } ``` Negative values are also allowed. If using negative values, the animation will start as if it had already been playing for N seconds. In the following example, the animation will start as if it had already been playing for 2 seconds: [S1] ```css div { width: 100px; height: 100px; position: relative; background-color: red; animation-name: myAnimation; animation-duration: 4s; animation-delay: -2s; } ``` **Set How Many Times an Animation Should Run** The `animation-iteration-count` property specifies the number of times an animation should run. The following example will run the animation 3 times before it stops: [S1] ```css div { animation-iteration-count: 3; } ``` The following example uses the value "infinite" to make the animation continue for ever: [S1] ```css div { animation-iteration-count: infinite; } ``` **Specify the Speed Curve of the Animation** The `animation-timing-function` property specifies the speed curve of the animation. The `animation-timing-function` property can have the following values: [S1] - `ease` β specifies an animation with a slow start, then fast, then end slowly (this is default). [S1] - `linear` β specifies an animation with the same speed from start to end. [S1] - `ease-in` β specifies an animation with a slow start. [S1] - `ease-out` β specifies an animation with a slow end. [S1] - `ease-in-out` β specifies an animation with a slow start and end. [S1] - `cubic-bezier(n,n,n,n)` β lets you define your own values in a cubic-bezier function. [S1] The following example shows the different speed curves that can be used: [S1] ```css #div1 {animation-timing-function: linear;} #div2 {animation-timing-function: ease;} #div3 {animation-timing-function: ease-in;} #div4 {animation-timing-function: ease-out;} #div5 {animation-timing-function: ease-in-out;} ``` ## π οΈ μ μ© μ¬λ‘ (Applied in summary) The page applies a 2-second positive delay and a -2-second negative delay to a `