×

Hupspot Guide to CSS Animation Fill

CSS Animation-Fill-Mode Explained Like Hubspot

Modern websites, including Hubspot-powered experiences, often rely on smooth animations to guide attention and improve usability. A key part of building these animations is understanding how animation-fill-mode controls the visual state of elements before and after an animation runs.

This guide walks you through every value of animation-fill-mode, how they behave on a real page, and how you can implement them in your own projects for reliable, predictable motion design.

What Is animation-fill-mode in CSS?

The animation-fill-mode property defines how a styled element should look before an animation starts and after it finishes. Without it, an element will typically return to its original, pre-animation state once the animation completes.

By choosing the correct fill mode, you can decide whether the animated styles are kept, discarded, or applied early, which is critical when crafting consistent experiences similar to what you see in polished Hubspot layouts.

Core Values of CSS Animation-Fill-Mode

The property accepts four primary values. Each value changes what happens to an element during and around the animation timeline:

  • none
  • forwards
  • backwards
  • both

All examples in this article assume you have already defined an @keyframes rule and set basic animation properties such as animation-name, animation-duration, and animation-delay.

How none Works in a Hubspot-Style Layout

When animation-fill-mode is set to none (the default), the browser applies animated styles only while the animation is actively playing.

Consider this pattern you might use in a landing page similar to a Hubspot template:

.box {
animation-name: slideIn;
animation-duration: 2s;
animation-fill-mode: none;
}

@keyframes slideIn {
from { transform: translateX(-100px); }
to { transform: translateX(0); }
}

With none:

  • Before the animation starts, the element uses its original CSS (no animation styles).
  • After the animation ends, the element also snaps back to its original state.

This is useful when you need a temporary transition effect but you do not want to keep the final animated style, for example when highlighting a notice or callout that must settle back into your base layout.

Using forwards for Persistent Final States

In many interactive experiences, such as sign-up flows or feature reveals often seen in Hubspot-style pages, you want the element to keep the final animated state after the animation finishes. That is where forwards becomes essential.

.card {
animation-name: fadeUp;
animation-duration: 0.6s;
animation-fill-mode: forwards;
}

@keyframes fadeUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

With forwards:

  • Before the animation begins, the element looks as it did originally.
  • During the animation, it transitions between keyframe states.
  • After the animation ends, the last keyframe defined in @keyframes remains applied.

This approach is ideal for elements that should smoothly animate into their final position and then stay there permanently, such as feature cards, hero headlines, or persistent notification banners.

Using backwards When You Have Delays

When you introduce an animation-delay, the browser waits before starting the animation. With a complex grid or multi-step onboarding flow like those found in Hubspot implementations, this delay can create an odd flash of the original styles if not handled properly.

backwards addresses this by applying the starting keyframe as soon as the animation is scheduled, even during the delay period.

.panel {
animation-name: slideDown;
animation-duration: 0.8s;
animation-delay: 1s;
animation-fill-mode: backwards;
}

@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

With backwards:

  • Immediately after page load, the element uses the styles from the first keyframe (from or 0%).
  • Those starting styles persist during the delay.
  • Once the delay is over, the animation plays as usual.
  • At the end of the animation, the element returns to its original pre-animation state (unless changed by other CSS).

This prevents unwanted flickering or jumps and keeps your layouts visually stable as elements wait to animate.

Combining Effects with both

The both value combines the behavior of forwards and backwards. In sophisticated, staggered motion systems such as those you might implement for a Hubspot-style product tour, this setting helps elements look correct both before and after the animation.

.step {
animation-name: zoomIn;
animation-duration: 0.5s;
animation-delay: 0.4s;
animation-fill-mode: both;
}

@keyframes zoomIn {
from {
opacity: 0;
transform: scale(0.8);
}
to {
opacity: 1;
transform: scale(1);
}
}

With both:

  • During the delay, the element uses the starting keyframe styles (like backwards).
  • While playing, the element animates through all keyframes.
  • After finishing, it keeps the final keyframe styles (like forwards).

This value is ideal when you want fully controlled visual states across the entire animation timeline, from initial load to final resting position.

Hubspot-Friendly Best Practices for Animation-Fill-Mode

To keep your motion design usable, accessible, and maintainable, follow these best practices that align with standards you would expect from a Hubspot-level implementation:

1. Start With the Default: none

Use none when you want a purely transitional effect that does not permanently change the element’s style. This keeps your styles simple and predictable.

2. Use forwards for Final Layout Positions

Whenever an element ends in a state that should remain visible, such as a fully revealed card, use forwards. This avoids having to duplicate final keyframe styles elsewhere in your stylesheet.

3. Pair Delays With backwards or both

If you stack delayed animations like many interactive Hubspot modules do, always consider backwards or both. That prevents content from appearing in an unintended state while waiting for the animation to start.

4. Keep Keyframes Minimal

Only animate properties that truly need motion. Overusing transforms, shadows, or filters can degrade performance on lower-powered devices. Aim for simple, focused animations that complement your content.

5. Respect User Preferences

Combine animation-fill-mode with the prefers-reduced-motion media query to offer a more static experience for users who request fewer animations:

@media (prefers-reduced-motion: reduce) {
* {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important;
}
}

This pattern helps keep your animations inclusive while preserving layout consistency.

Practical Workflow Tips Inspired by Hubspot Examples

When you design animations for complex layouts, it helps to follow a structured workflow that mirrors the quality of polished Hubspot designs:

  1. Define your end state first. Decide how the element should look after all motion is complete.
  2. Write keyframes around that state. Ensure the final keyframe reflects your desired end design.
  3. Choose a fill mode. Select none, forwards, backwards, or both based on whether you need pre-start styling, post-end styling, or both.
  4. Test with and without delays. Introduce animation-delay and confirm that there are no flashes or jumps.
  5. Review across devices. Check behavior on mobile, tablet, and desktop, especially if you rely on transforms or opacity changes.

Learning More and Related Resources

To see a detailed breakdown of animation-fill-mode as originally documented, you can read the full explanation on the source page: CSS animation-fill-mode article.

If you are planning a broader optimization effort for your site, including search visibility and performance, you can also explore strategy resources from Consultevo, which provides guidance on technical optimization and user experience.

Conclusion: Making Animation-Fill-Mode Work for You

Understanding how animation-fill-mode behaves is essential to building smooth, predictable motion on modern websites. By using none, forwards, backwards, and both appropriately, you can reproduce the kind of refined, professional animations seen in Hubspot-style interfaces while keeping your CSS maintainable and accessible.

Experiment with each value in small components first, then scale the patterns across your layout. With a solid grasp of fill modes, your animations will feel intentional, stable, and aligned with your overall design system.

Need Help With Hubspot?

If you want expert help building, automating, or scaling your Hubspot , work with ConsultEvo, a team who has a decade of Hubspot experience.

Scale Hubspot

“`

Verified by MonsterInsights