For years, building a clean entry animation meant writing a @keyframes block, setting an initial hidden state, then toggling a class with JavaScript after a short delay. You probably wrote that pattern dozens of times. It worked, but it felt fragile. One missed timeout, one race condition on page load, and the animation either flashed the element in its final state or never ran at all. The new CSS @starting-style rule fixes that. It lets you define what an element looks like before its animation runs, without any JavaScript, without any animation-delay hacks, and without the dreaded flash of unstyled content.
The CSS @starting-style rule is a new at-rule that defines the initial state of an animated element before its first keyframe executes. It eliminates the need for JavaScript to set up entry animations, prevents content flashes on load, and works seamlessly with existing @keyframes. By using @starting-style, frontend developers can write cleaner, more maintainable CSS and improve page performance by removing startup scripts.
How the old approach slowed you down
Before we look at the new syntax, let’s be honest about the old way. You probably used something like this:
.hero {
opacity: 0;
transform: translateY(20px);
}
.hero.visible {
animation: fadeInUp 0.6s ease-out forwards;
}
Then in your HTML or JavaScript, you added a class after a tiny delay:
window.addEventListener('load', () => {
document.querySelector('.hero').classList.add('visible');
});
That pattern has problems. The element starts invisible, so if the CSS loads late, users see a blank space. If the JavaScript fails, the element stays hidden forever. And you need to manage timing across multiple elements manually.
The @starting-style rule removes all of that.
Understanding the @starting-style at-rule
The @starting-style rule works like a companion to @keyframes. You define a set of CSS declarations that apply only at the very beginning of the animation, before the first keyframe takes effect. The browser applies these styles instantly when the page renders, then transitions into the first keyframe of your animation.
Here is the basic syntax:
@starting-style(selector) {
opacity: 0;
transform: translateY(20px);
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.hero {
animation: fadeInUp 0.6s ease-out;
}
The browser sees the @starting-style block, applies those styles to .hero immediately on page load, and then runs the fadeInUp animation. No JavaScript. No flash. No race conditions.
When you should use @starting-style
The rule shines in a few specific scenarios. Here are the most common ones:
- Hero sections and landing page headers: You want a fade-in or slide-up effect without the user seeing the raw layout first.
- Modal and overlay entrances: The element should start invisible, then animate in when triggered.
- Staggered list animations: Each list item starts from a different offset before animating into place.
- Page-load brand animations: A logo or tagline that fades in from a custom starting state.
The rule works with any CSS property that can be animated. You are not limited to opacity and transforms. You can set clip-path, filter, background-position, or even grid-template-rows as a starting style.
A practical numbered workflow
Let me walk you through a real implementation. Suppose you have a testimonial section with three cards that should slide in from the right on page load.
- Write the keyframes first. Define the animation that brings the card to its final resting state.
@keyframes slideIn {
from {
transform: translateX(100px);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
- Add the @starting-style block for each card. Use a unique selector or a common class.
@starting-style(.card) {
transform: translateX(100px);
opacity: 0;
}
- Apply the animation to the elements. No need to set initial properties on the element itself.
.card {
animation: slideIn 0.5s ease-out;
}
- Stagger the animations with animation-delay. This is where the real power shows. You can delay each card without worrying about the starting state.
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.4s; }
The @starting-style rule ensures all cards start from the same hidden state, regardless of when their animation actually begins.
Common mistakes and how to avoid them
Even with a clean syntax, there are a few pitfalls. Here is a table that shows the most frequent mistakes and the correct approach.
| Mistake | What happens | How to fix it |
|---|---|---|
Using animation-fill-mode: forwards on the element |
The starting style may be overridden by the final keyframe state. | Only use forwards if your animation ends in a different state than the element’s default. Otherwise, omit it. |
Putting @starting-style inside a media query |
The rule is not scoped to media conditions. It applies globally. | Use the selector inside @starting-style to target elements only in certain breakpoints. |
Forgetting to match properties between @starting-style and @keyframes |
The animation may jump or flash if the starting style does not match the from keyframe. |
Copy the exact property values from the from keyframe into your @starting-style block. |
Using @starting-style with animation-iteration: infinite |
The starting style only applies once on load. Looping animations ignore it. | Use @starting-style only for one-shot entry animations. |
Nesting @starting-style inside another at-rule like @media or @supports |
The rule is not designed for nesting. It will be ignored. | Keep @starting-style at the top level of your stylesheet. |
Expert advice: Always test your entry animations with a slow network connection. Use a tool like the WebPageTest browser extension to simulate a 3G connection. If your
@starting-styleproperties match yourfromkeyframe exactly, the animation will be seamless. If they do not match, you will see a brief flicker.
Comparing @starting-style with older techniques
The old methods all had tradeoffs. Let me break them down in a clear table.
| Technique | Lines of code | JavaScript needed | Flash risk | Browser support |
|---|---|---|---|---|
| JavaScript class toggle | 10+ | Yes | High | All browsers |
animation-delay with hidden state |
8 | No | Medium | All browsers |
<noscript> fallback |
12 | Yes | Low | All browsers |
@starting-style rule |
4 | No | None | Modern browsers in 2026 |
The @starting-style rule is the only approach that eliminates the flash entirely without requiring a separate hidden state in your main CSS. It also keeps your animations declarative, which means they work even if JavaScript is disabled.
How it works with complex selectors
You are not limited to simple class names. The @starting-style rule accepts any valid CSS selector. You can target elements based on attributes, structure, or state.
@starting-style([data-animate="hero"]) {
filter: blur(4px);
opacity: 0;
}
@starting-style(.gallery > li:nth-child(odd)) {
transform: rotate(-3deg) scale(0.95);
}
This flexibility lets you create sophisticated entrance patterns without duplicating styles across multiple elements.
Performance implications
Because @starting-style is a pure CSS feature, it loads and executes before the browser paints the first frame. There is no JavaScript startup cost, no DOM manipulation, and no extra network requests. The styles are part of the initial CSSOM, so they apply instantly.
For pages with many animated elements, this can reduce the time to first meaningful paint. The browser does not need to wait for JavaScript to load and run before starting the animation. It simply reads the @starting-style block, applies the styles, and renders the first frame with those styles active.
If you are interested in other ways to optimize your frontend workflow, check out our guide on how to optimize your front-end workflow with cutting-edge tools.
What about fallback behavior
The @starting-style rule is part of the CSS Cascading and Inheritance Level 6 specification. It is supported in all major browsers as of mid-2026. For older browsers that do not support it, the rule is ignored entirely. Your element will simply start in its default state without the entry animation.
To handle this gracefully, set your element’s default styles to look acceptable without the animation. For example, if your starting style sets opacity: 0, your element should have opacity: 1 as its default. That way, unsupported browsers show the content immediately, while supported browsers fade it in.
.card {
opacity: 1; /* fallback for older browsers */
}
@starting-style(.card) {
opacity: 0;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.card {
animation: fadeIn 0.4s ease-in;
}
This pattern ensures no content is ever hidden from users on older browsers.
The future of declarative entry animations
The @starting-style rule is part of a larger push in CSS toward declarative page lifecycle management. Other new features like the @scope rule and the view-transition API are moving toward a world where JavaScript is no longer required for common interaction patterns. If you want to stay ahead of these changes, reading about 5 new CSS features that will change your workflow in 2026 is a good next step.
Putting it all together
Here is a complete example that uses @starting-style to create a staggered entrance for a three-column feature section.
@starting-style(.feature) {
opacity: 0;
transform: scale(0.9);
}
@keyframes popIn {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}
.feature {
animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.feature:nth-child(1) { animation-delay: 0s; }
.feature:nth-child(2) { animation-delay: 0.15s; }
.feature:nth-child(3) { animation-delay: 0.3s; }
Copy that into your stylesheet, add the .feature class to your HTML elements, and the animation works immediately. No JavaScript, no extra markup, no hidden divs.
For more on modern animation techniques, see master modern web animations with CSS and JavaScript techniques.
Start using @starting-style today
The @starting-style rule is one of those rare CSS features that simplifies your code, improves performance, and removes a whole class of bugs all at once. It is stable, well-supported, and easy to add to existing projects.
Open up a stylesheet you are working on. Find an entry animation that currently depends on JavaScript. Replace it with @starting-style and a matching @keyframes block. Watch the flash disappear. Notice how the page feels snappier. Enjoy writing one less script tag.
That is the future of CSS in 2026: less ceremony, more motion, and a lot fewer things to break.