Glossary of web design terms you should know
Create your website in 60 seconds with AI. Start for free!
Generate a websiteKeyframes
Keyframes play an important role in creating animation for your website, especially when you're aiming for engaging transitions or motion effects. Whether you're using CSS or JavaScript-based animation, keyframes help define the specific points where a change should happen. These changes might involve position, color, scale, or any visual property you want to animate. Knowing how keyframes work gives you more control over how your site looks and feels during animations.
How keyframes work in web design
In web design, keyframes define the start and end points of an animation, along with any intermediate points. Using CSS, you can create smooth transitions that guide the viewer’s attention or enhance the overall experience. Keyframes are usually written in the @keyframes
rule, which sets up what happens during each stage of the animation. You assign that animation to an HTML element using CSS properties like animation-name
and animation-duration
.
For example, if you want a button to fade in and move slightly upward, keyframes will allow you to control each frame of that effect. These animations are processed by the browser and can run smoothly without extra code or JavaScript. Understanding keyframes lets you add motion to your site while keeping it fast and visually appealing.
Why keyframes matter for user experience
Good animation can create a more polished and user-friendly site. Keyframes let you bring elements to life without overwhelming the viewer. When used correctly, they make the interface feel responsive and interactive, guiding users through your content with subtle visual cues. This is especially useful for things like loading indicators, navigation changes, or interactive elements like modals and sliders.
Bad or overused animations, on the other hand, can feel clunky and slow. That’s why keyframes should be used intentionally—too much motion can be distracting, while a little movement can make your site feel more refined and easier to use. When paired with other UX best practices, keyframes help enhance the overall design of a page.
How to use keyframes in CSS
To use keyframes in CSS, start by writing a @keyframes
rule that defines what changes during the animation. You set the animation’s name and declare stages with percentages—like 0%
for the start, 50%
for the midpoint, and 100%
for the end. Then, you apply this animation to a specific element using properties such as animation-name
, animation-duration
, and animation-timing-function
.
Here’s a basic example:
css
CopyEdit
@keyframes slideFade {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
``
.button {
animation-name: slideFade;
animation-duration: 0.5s;
animation-fill-mode: forwards;
}
This example makes a button fade in and slide upward when it appears. With practice, you can use keyframes to create more complex and interactive animations for your website.
Keyframes vs transitions: what's the difference?
CSS transitions are great for simple effects, like changing a color on hover or animating between two states. You don’t need @keyframes for transitions—just define a starting and ending point, and the browser handles the rest. Transitions are ideal when you only need a one-step change.
Keyframes are more flexible because they allow you to define multiple stages in an animation. For example, you can animate an object to bounce, pulse, or move in a complex path. This makes keyframes the better option when you need more control and timing in your animations. Both can be used together in a well-designed site, depending on the effect you're going for.
FAQs about keyframes
What are keyframes in CSS used for?
Keyframes in CSS are used to define the specific stages of an animation. They let you control how an element should look at certain points during its animation, making it possible to create smooth, multi-step motion effects without JavaScript.
Can I use keyframes with JavaScript too?
Yes! While CSS keyframes are great for most animations, JavaScript can also be used to create more dynamic or interactive keyframe animations. Libraries like GSAP (GreenSock) are built specifically for this purpose, giving you more control over timing and responsiveness.
What’s the difference between 0%, 50%, and 100% in keyframes?
These percentages represent the progress of the animation. 0% is the starting state, 100% is the final state, and any value in between (like 50%) lets you define how the element should appear halfway through. This lets you choreograph complex movement step-by-step.
Are keyframes good for SEO?
While SEO is mostly about content and structure, animations using keyframes can affect user engagement, which can indirectly influence SEO. For example, if a site feels smooth and engaging, visitors might stay longer, helping with bounce rates and time-on-page metrics.
Do keyframes work on all browsers?
Most modern browsers support CSS keyframes, but it's always smart to test your animations across different platforms. You may need vendor prefixes (-webkit-, -moz-, etc.) for older versions, though support is generally very good today.
Want animations that actually help your business?
Well-placed animations can seriously improve how people experience your website. Whether you're just adding subtle transitions or building full-on effects with keyframes, using the right tools makes it easier and faster. B12’s AI website builder lets you create a polished, professional site that moves with intention. Sign up and build a website that feels alive—in all the right ways.
Draft your site in 60 seconds
Get an AI website made specifically for you that's free to launch.
Start for free ✨No credit card required
Draft your website in 60 seconds
In just a few clicks, build a website with all the features you need to thrive online