CSS Reference ยท At-rules
The @starting-style at-rule
Reference for the CSS @starting-style at-rule: define the style an element transitions from when it first renders, fade in new elements, dialogs and popovers.
A CSS transition needs a "before" and an "after" style. When an element has just been inserted into the page, or changed from display: none, it has no earlier style to transition from, so it simply appears. The @starting-style at-rule supplies that missing "before" value: the browser uses it as the element's style on its first style update, then transitions to the normal styles.
It lets you build entry animations in plain CSS, with no JavaScript class toggling or forced reflow.
.toast { opacity: 1; transition: opacity 0.4s; @starting-style { opacity: 0; } }
Try it
Each new item slides down and fades in. Remove the @starting-style block and items pop in with no animation.
Hiding uses allow-discrete so display flips to none only after the fade-out ends. Showing again triggers the starting style, so the panel fades in.
Syntax
@starting-style { <rule-list> } selector { @starting-style { <declarations> } }
It is an at-rule, so initial value, inheritance and animatability do not apply.
Syntax and arguments
| Form | Description |
|---|---|
Top-level @starting-style { rules } |
Contains ordinary rules. Matching declarations act as the starting values. |
| Nested inside a rule | Contains declarations (or nested rules) for that rule's element. |
| Specificity | Starting-style rules take part in the normal cascade, so they need the same specificity as the rule they override. |
Usage notes
- When it applies. The starting style is used for the first style update after an element is added to the DOM, after it changes from
display: noneto something visible, and when a popover or<dialog>opens in the top layer. - It only matters with a transition. Without a
transition(or animation) on the property, the starting values are never visible. - Match specificity. A starting rule with lower specificity than the real rule loses the cascade. Write both with the same selector.
- Only the first frame. Later changes use ordinary transitions, not
@starting-style. - Exit animations need
transition-behavior: allow-discreteondisplay(andoverlayfor top-layer elements) so the element stays rendered while it fades out. - Respect motion preferences. Wrap larger movements in
@media (prefers-reduced-motion: no-preference).
Browser support
Supported in current Chrome, Edge, Safari and Firefox, and part of Baseline since 2024. In an older browser the element simply appears without animation, which is a safe fallback.
Related
transitionโ the shorthand for transitionstransition-behaviorโ allow discrete properties such asdisplayto transition:popover-openโ the open state of a popover- Lesson: Transitions