More options for styling <details>

As of Chrome 131 you have more options to style <details> and <summary>.

You can now set display property values other than block on these elements, and also use a ::details-content pseudo-element to style the part that expands and collapses.

The following demo featuring a horizontal accordion uses all these features:

See the Pen
Styling <details>: Horizontal Accordion
by web.dev (@web-dot-dev)
on CodePen.

If your browser does not support these features yet, check out the reference recording at the top of this post. At the time of writing, only Chrome supports these additions. The PR to add this to WebKit already got merged on main, so you can also expect this in an upcoming Safari release.

Go read my article on developer.chrome.com to learn all about it.

Read the article →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.