← blog
CSSNovember 27, 2026 · 6 min read

CSS Transitions Skip display: none. transition-behavior Fixes That.

You can finally animate a dialog in from display: none without JavaScript — transition-behavior and @starting-style turn the jump-cut into a real transition.

Parsa Jiravand · Frontend engineer · building bestpractic
CSS Transitions Skip display: none. transition-behavior Fixes That.

You build a dialog. You add transition: opacity 0.2s, transform 0.2s. You open it.

It just appears. No fade, no slide — a jump-cut, like someone spliced the film.

You check the transition is spelled right. It is. You check the element is actually changing opacity. It is — from 0 to 1, exactly like you wrote it. So why does it still snap?

Because the element isn't only changing opacity. It's also going from display: none to display: block, and CSS has never known how to transition that.

display isn't a number, a color, or a length. You can interpolate opacity: 0 to opacity: 1 because the browser can compute every value in between — 0.3, 0.7, whatever the easing curve wants at that frame. There is no value "in between" none and block. An element is either laid out or it isn't.

Properties like this are discrete: display, content-visibility, overlay, visibility (sort of — more on that below). The browser's only option has always been to flip them the instant the transition starts, which for display means none → block happens at frame zero, before your opacity transition even gets going.

So the classic workaround was: don't touch display at all.

CSS
1
2
3
4
5
6
7
8
9
.modal { opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s; } .modal.open { opacity: 1; visibility: visible; }

visibility gets special-cased by the spec — browsers flip it to visible at the start of the duration when opening, and to hidden at the end when closing, so it doesn't clip the fade. It works, and it's not even an accessibility bug: visibility: hidden does pull the element out of the accessibility tree and the tab order while it's hidden. The real downside is layout — visibility: hidden never collapses the box, so the element still occupies its space the whole time, leaving a gap or pushing siblings around until you cover it with something else. The actual fix, for years, meant display: none toggled from JavaScript on a transitionend listener, timed by hand, one more thing to get wrong.

Guess which part people got wrong most. If you said "the timeout that doesn't match the CSS duration," you've shipped this bug too.

transition-behavior: allow-discrete tells the browser: include this property in the transition anyway. Instead of flipping at frame zero, a discrete property now flips at the very end of the transition when going from a value to none-equivalent, or at the very start when going the other way — same rule visibility already followed, just available to properties that never had it.

CSS
1
2
3
4
5
6
7
8
9
.modal { display: none; opacity: 0; transition: opacity 0.2s, display 0.2s allow-discrete; } .modal.open { display: block; opacity: 1; }

Try that alone, though, and you'll hit the next wall. The modal now fades out correctly — display stays block for the full duration while opacity eases to 0, then flips to none. But fading in still snaps, because on the very first frame the element goes straight to display: block; opacity: 1. There's no "starting point" to ease from — the element didn't exist in a transitionable state a moment ago.

That's what @starting-style is for.

CSS
1
2
3
4
5
6
7
8
9
10
11
12
13
.modal { display: none; opacity: 0; transition: opacity 0.2s, display 0.2s allow-discrete; @starting-style { opacity: 0; } } .modal.open { display: block; opacity: 1; }

@starting-style defines the values the browser should treat as "the frame before this element entered the DOM or became displayable." Without it, there's nothing before frame zero to transition from — the browser has no prior value, so it has nothing to interpolate. With it, the moment display flips to block, the element starts at the @starting-style values and transitions toward its real ones.

Three pieces, each covering a gap the others leave:

  • allow-discrete lets display itself sit in the transition queue instead of jumping
  • @starting-style gives the element an entry state to animate from
  • your normal transition and target values do the actual easing, same as always

Drop any one and you're back to a jump-cut on either the way in, the way out, or both.

Toggle the panel below with and without allow-discrete wired up. Same markup, same duration — the only difference is whether display is allowed into the transition.

Runs right in your browser — poke at it and watch the concept react live.

content-visibility: hidden and the native <dialog>/popover overlay property are discrete too, and they're exactly where this combination earns its keep — you get the rendering-skip benefits of content-visibility and an entrance animation, which used to be mutually exclusive. If you're already using content-visibility: auto to skip offscreen rendering, allow-discrete is how you animate the same element's reveal without giving that performance win back.

One honest caveat: this is about transition, not animation. Keyframe animations have had @starting-style-adjacent control for longer via animation-fill-mode, and discrete properties behave a little differently inside @keyframes than inside a plain transition. If your modal uses animation instead of transition, check the specific property's behavior before assuming allow-discrete is even the piece you're missing.

And it's not magic for every discrete property — transition-behavior: allow-discrete only changes when the flip happens relative to the transition's duration. It still can't interpolate display: block to display: flex, because those aren't "on vs off," they're two different values with no path between them. The trick only works for the none ↔ something-else case.

Support is more uneven than it looks. Chrome 117 shipped the full combination — including animating display itself — soon after transition-behavior landed. Safari took two steps: 17.4 added transition-behavior and parsed allow-discrete, but didn't extend the discrete-property flip to display until Safari 18. Firefox shipped transition-behavior and @starting-style in 129, but as of late 2026 it still doesn't reliably transition display itself — closing transitions in particular can cancel and jump straight to none instead of running the full duration, a long-standing, still-open limitation rather than a recent regression. So build for the gap: the worst case should be the old jump-cut, not broken layout, but on today's Firefox that jump-cut can still show up on close.

Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.

That jump-cut modal isn't a display bug you work around anymore — it's three CSS features doing exactly what they say: allow-discrete admits the property into the transition, @starting-style gives it a place to start from, and your existing transition line does the rest.

Next time you reach for a setTimeout to delay a display: none, try deleting it instead. What's the last place in your codebase where JavaScript is still faking something CSS can now do natively? I'd genuinely like to know — drop it in the comments.


🚀 Want more like this? Every guide, playground, and quiz lives on bestpractic.org — open it and sign up free so the next one finds you.

Thanks for reading! Let's stay connected:

Keep reading

One post a day, in your inbox

Each one with a runnable playground and a quiz. No pitch, no digest, unsubscribe in one click.

0 comments

Sign in to join the discussion, like comments, and save articles for later.