<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq" -->

---
title: CSS animations to bring your site to life | daily.dev
description: A walkthrough of building animated expandable info cards using the native HTML details/summary elements combined with modern CSS features like...
canonical: https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: CSS animations to bring your site to life | daily.dev
og:description: A walkthrough of building animated expandable info cards using the native HTML details/summary elements combined with modern CSS features like...
og:url: https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq
og:image: https://api.daily.dev/og/posts/8eOv3hbFq.png
og:image:alt: CSS animations to bring your site to life
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# CSS animations to bring your site to life

**[Kevin Powell](https://daily.dev/sources/kevinpowell)** · 16 min read · 2 upvotes · 0 comments

## Summary

A walkthrough of building animated expandable info cards using the native HTML details/summary elements combined with modern CSS features like content-visibility, transition-behavior: allow-discrete, and interpolate-size. Covers structuring content with flow content restrictions in summary, using block-size transitions for open/close animations, staggering child element animations with transition-delay and calc(), and handling first-render animation quirks. Ends with a plug for the creator's CSS course.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=ZSNiSdB8Ens>

## Questions this post answers

### How do I animate the open and close transition of an HTML details element in CSS?

Set block-size to 0 by default and to auto when the details element has the open attribute, then add a transition on block-size along with transition-behavior: allow-discrete so the discrete content-visibility change animates smoothly instead of snapping instantly. Also add interpolate-size: allow-keywords on the root element so transitions to auto work, and use overflow: hidden to avoid content spilling during the animation.

_daily.dev surfaces techniques like this for developers polishing CSS-only interactive components._

### Why does my CSS transition on a details element only work when opening but not when closing?

The details content pseudo-element has a built-in content-visibility: hidden style that switches instantly rather than transitioning, so closing appears to snap shut. Adding transition-behavior: allow-discrete to the transition lets content-visibility change smoothly alongside block-size, fixing the one-directional animation problem so both opening and closing animate.

_developers debugging one-directional CSS transitions can find similar fixes tracked on daily.dev._

### What elements are allowed inside an HTML summary tag?

Only flow content restricted to phrasing-type content is allowed inside summary, unlike the details element itself which accepts any flow content such as div. Using a div inside summary works in some browsers but is not spec-compliant; span elements are the correct choice for formatting text and inline content within a summary.

_daily.dev helps developers keep up with semantic HTML rules like this while building accessible components._

## Similar posts on daily.dev

- [Scroll-driven CSS animations](https://daily.dev/posts/scroll-driven-css-animations-uw6plcluy) · Flavio Copes · 141 upvotes · 6 comments
- [::details-content: style expandable content without wrapp...](https://daily.dev/posts/details-content-style-expandable-content-without-wrapp--sgkq45fvt) · Trevor Lasn · 0 upvotes · 0 comments
- [Staggered Animation with CSS sibling-\* Functions – Frontend Masters Blog](https://daily.dev/posts/staggered-animation-with-css-sibling--functions-frontend-masters-blog-o9x9nobox) · Frontend Masters · 0 upvotes · 0 comments
- [How to create awesome staggered animations in CSS](https://daily.dev/posts/how-to-create-awesome-staggered-animations-in-css-k09m57ftt) · LogRocket · 52 upvotes · 2 comments

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"CSS animations to bring your site to life","url":"https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq"},"datePublished":"2026-09-30T13:16:20.502Z","dateModified":"2026-09-30T15:03:44.088Z","description":"A walkthrough of building animated expandable info cards using the native HTML details/summary elements combined with modern CSS features like...","image":"https://i.ytimg.com/vi/ZSNiSdB8Ens/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/ZSNiSdB8Ens/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Kevin Powell","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kevin Powell","logo":"https://media.daily.dev/image/upload/s--XK5Rf0kM--/f_auto/v1717745137/logos/kevinpowell","url":"https://daily.dev/sources/kevinpowell"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"css","timeRequired":"PT16M","video":{"@type":"VideoObject","name":"CSS animations to bring your site to life","description":"A walkthrough of building animated expandable info cards using the native HTML details/summary elements combined with modern CSS features like...","thumbnailUrl":"https://i.ytimg.com/vi/ZSNiSdB8Ens/sddefault.jpg","uploadDate":"2026-09-30T13:16:20.502Z","duration":"PT16M","url":"https://api.daily.dev/r/8eOv3hbFq","embedUrl":"https://www.youtube.com/embed/ZSNiSdB8Ens"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kevin Powell","item":"https://daily.dev/sources/kevinpowell"},{"@type":"ListItem","position":3,"name":"CSS animations to bring your site to life"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/css-animations-to-bring-your-site-to-life-8eov3hbfq#faq","mainEntity":[{"@type":"Question","name":"How do I animate the open and close transition of an HTML details element in CSS?","acceptedAnswer":{"@type":"Answer","text":"Set block-size to 0 by default and to auto when the details element has the open attribute, then add a transition on block-size along with transition-behavior: allow-discrete so the discrete content-visibility change animates smoothly instead of snapping instantly. Also add interpolate-size: allow-keywords on the root element so transitions to auto work, and use overflow: hidden to avoid content spilling during the animation. daily.dev surfaces techniques like this for developers polishing CSS-only interactive components."}},{"@type":"Question","name":"Why does my CSS transition on a details element only work when opening but not when closing?","acceptedAnswer":{"@type":"Answer","text":"The details content pseudo-element has a built-in content-visibility: hidden style that switches instantly rather than transitioning, so closing appears to snap shut. Adding transition-behavior: allow-discrete to the transition lets content-visibility change smoothly alongside block-size, fixing the one-directional animation problem so both opening and closing animate. developers debugging one-directional CSS transitions can find similar fixes tracked on daily.dev."}},{"@type":"Question","name":"What elements are allowed inside an HTML summary tag?","acceptedAnswer":{"@type":"Answer","text":"Only flow content restricted to phrasing-type content is allowed inside summary, unlike the details element itself which accepts any flow content such as div. Using a div inside summary works in some browsers but is not spec-compliant; span elements are the correct choice for formatting text and inline content within a summary. daily.dev helps developers keep up with semantic HTML rules like this while building accessible components."}}]}
```

