DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

CSS @starting-style: Make Elements Animate When They First Appear

CSS @starting-style gives transitions a before-state when an element first appears or returns from display: none. Learn the patterns for entry, exit, dialogs, popovers, and reduced motion.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use CSS @starting-style when an element needs to transition into view but has no previously rendered style to transition from. Pair it with a normal visible-state rule and a transition; for dialogs, popovers, or other elements changing from display: none, also account for discrete display transitions.

Why an element needs a starting style

A CSS transition interpolates between an element’s previous and new computed styles. When an element is rendered for the first time—or becomes visible after display: none—there may be no previous rendered state. The browser then has no before-value from which to run the transition. The @starting-style at-rule supplies that initial value for the entry transition.

As an Amazon Associate I earn from qualifying purchases.

It is for transitions, not a prerequisite for CSS keyframe animations: a keyframe animation already defines its own starting keyframe. Use @starting-style when you want a transition between states and the entering element lacks a prior style state.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Animate a newly appearing element

Set the final, visible values in the ordinary rule, declare the properties to transition, and put the entry values in @starting-style. This standalone form follows MDN’s documented syntax:

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
.notice {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

@starting-style {
  .notice {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

When .notice first appears, the starting values provide its before-state and the ordinary rule provides its destination. The browser transitions opacity and position between them. The duration and easing above are example author choices, not browser requirements.

Choose standalone or nested syntax

You can also nest @starting-style inside the selected rule. In this form, the starting declarations are scoped to that rule:

.panel {
  opacity: 1;
  transition: opacity 200ms;

  @starting-style {
    opacity: 0;
  }
}

Both forms are documented by MDN. With the standalone form, the starting-style selector has the same specificity as the corresponding ordinary selector. If declarations have equal specificity, put the standalone block after the normal rule so source order does not override the starting value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make display changes transition

display is a discrete property: it does not interpolate through intermediate values. To transition an element from display: none to a visible display value, include display in the transition and enable discrete transitions with allow-discrete. For example, a popover can use its open state as the destination:

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
.popover {
  opacity: 0;
  transform: translateY(0.5rem);
  display: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    display 180ms allow-discrete;
}

.popover:popover-open {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

@starting-style {
  .popover:popover-open {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

The allow-discrete behavior lets display participate in the transition even though it does not interpolate. On entry, the visible display value takes effect at the start so the other properties can animate. The :popover-open selector is the destination state; the popover itself must be opened through the relevant HTML interaction or script.

Keep dialogs and popovers in the top layer during exit

Browsers manage whether modal dialogs and popovers belong to the top layer. For an exit transition, include overlay in the transition list with allow-discrete, as well as display. This delays removal from the top layer until the visual transition finishes:

.dialog {
  opacity: 0;
  transform: translateY(0.5rem);
  display: none;
  overlay: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease,
    display 180ms allow-discrete,
    overlay 180ms allow-discrete;
}

.dialog:open {
  opacity: 1;
  transform: translateY(0);
  display: block;
  overlay: auto;
}

@starting-style {
  .dialog:open {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

Here :open represents the dialog’s open state. The dialog still needs to be opened and closed using the appropriate dialog behavior; CSS controls the transition rather than the interaction. The discrete display transition keeps the element rendered through its exit, while overlay delays its top-layer removal. See Chrome’s entry and exit animation examples for additional patterns and context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand entry and exit as different states

A starting style supplies the before-state for the initial appearance, or for a return from display: none. It does not become the element’s normal reverse state. When a shown element closes, it transitions from its visible values toward its ordinary hidden or default values. Entry and exit can therefore use different rules and need not be symmetrical.

For a simple element whose visibility is controlled by a class, the same principle applies: the visible class is the destination, and the starting-style rule supplies the initial values when that state first renders. For more involved DOM changes, view transitions are another technique to consider; they solve a broader class of DOM-transition problems and are not automatically preferable to a state-based CSS transition.

Respect reduced-motion preferences

Some users ask their operating system or browser to reduce motion. Use prefers-reduced-motion: reduce to remove, shorten, or replace nonessential movement. A straightforward option is to disable the transition for those users:

@media (prefers-reduced-motion: reduce) {
  .notice,
  .popover,
  .dialog {
    transition: none;
  }
}

If a transition is useful for conveying a state change, you can instead replace a large movement with a less movement-intensive effect. MDN documents the preference and its use in CSS at the prefers-reduced-motion media feature reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check browser support for your audience

MDN classifies @starting-style as Baseline 2024 and says it has worked across the latest browser versions since August 2024. That is a broad compatibility milestone, not a minimum-version guarantee for every browser, embedded webview, or device. Check the compatibility data for the browsers your project supports, especially if older versions matter. See MDN’s @starting-style reference for the feature’s syntax, behavior, and compatibility information.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.