CSS animation: plainly explained.

A CSS animation changes an element's styles over time with keyframes. How it works, animation versus transition, and performance best practices.

Design · Updated Nov 7, 2026

DEFINITION

A CSS animation makes an element change styles over time using keyframes, adding motion like fades, slides or loops without JavaScript.

CATEGORY

Design

Summarize this page with AI

A CSS animation makes an element change its styles over time, following a set of keyframes, to create motion such as fades, slides, pulses or loops. It runs directly in the browser without JavaScript, which makes it lightweight and smooth for interface effects.

01

Keyframes and the animation properties

An animation has two parts: a @keyframes rule that describes the styles at points from 0% to 100%, and an animation declaration that plays them on the element.

  • @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  • animation: fade 300ms ease-in-out;
  • Sub-properties: animation-duration, -timing-function, -delay, -iteration-count, -direction, -fill-mode.
02

Animation versus transition

Both add motion, but they are triggered and shaped differently.

Aspect
TriggerTransitionNeeds a state change (hover, class)AnimationCan run on its own or on load
StepsTransitionTwo states, start and endAnimationMany keyframes
LoopingTransitionNoAnimationYes (iteration-count)
Best forTransitionHover and focus feedbackAnimationMulti-step or looping motion
03

Timing, iteration and fill

Beyond duration, a few properties shape how an animation feels. animation-iteration-count: infinite loops it, animation-direction: alternate plays it back and forth, and animation-fill-mode: forwards keeps the final state after it ends. The timing function (ease, linear, a custom cubic-bezier, or steps() for frame-by-frame) controls the pace.

04

Performance and accessibility

Animating transform and opacity is smooth because the browser can offload them to the GPU, while animating layout properties like width or top can cause jank. For accessibility, respect the prefers-reduced-motion setting so users who are sensitive to motion get a calmer experience.

05

CSS, JavaScript, Lottie or Rive

Use CSS for simple, decorative motion. Reach for JavaScript or a library like GSAP when you need complex sequencing or interactivity. For rich, designer-made vector animation, export from tools like Lottie or Rive and drop it into the page, keeping the CSS layer light.

06

CSS animation at BeBranded

At BeBranded we use motion with intent: subtle, performant animations that guide attention without slowing the page. For richer motion we combine CSS with tools like Lottie or Rive, as part of our design work.

FAQ

Questions about CSS animation.

Another question?

Write to us
What is a CSS animation?
A CSS animation makes an element change styles over time following keyframes, creating motion like fades, slides or loops directly in the browser without JavaScript.
What is the difference between a CSS animation and a transition?
A transition animates one change between two states, usually on an interaction. An animation can define many steps and run on its own or loop. Use transitions for simple state changes, animations for multi-step motion.
What are keyframes?
Keyframes describe the styles an element should have at points along an animation, from 0 percent to 100 percent. The browser interpolates the styles between them.
Are CSS animations good for performance?
They can be. Animating transform and opacity is smooth because the browser uses the GPU. Animating layout properties like width or top is heavier and can cause jank.
What is prefers-reduced-motion?
It is a user setting that signals a preference for less motion. Respecting it in CSS lets you reduce or remove animations for people who are sensitive to movement.
When should I use JavaScript instead?
Use JavaScript, or a tool like GSAP, when you need complex sequencing, interactivity, or fine control that keyframes alone cannot express. For simple, decorative motion, CSS is enough.

Related

Related terms, and where to go next.

Claude Design: what it changes for your website
AI & automation

Claude Design: what it changes for your website

Claude Design by Anthropic: what the tool actually does, its concrete limits, the pipeline to Webflow, and why a prototype is not a product.

Read the article
BeBranded
UX/UI

Responsive design: complete guide for 2026

Responsive design: definition, technical principles, breakpoints, Flexbox, Grid, fluid typography, how Webflow handles it, mistakes and best practices.

Read the article
BeBranded
Development

Figma to Webflow: the complete workflow in 2026

Figma to Webflow: prepare your mockup, use the plugin, Client-First rebuild, best practices and mistakes to avoid. Step-by-step guide.

Read the article

Let’s talk

Tell us what you want to build.

Thirty minutes with the people who will work on your project. You leave with a clear view of the scope, the timeline and the next steps.

What happens next

  1. 1A 30-minute callWe listen to your goals, your constraints and your context.
  2. 2A clear scopeWe map what is worth doing first, and what it takes.
  3. 3A costed proposalYou decide, with no commitment and no sales pitch.