For years, five very ordinary jobs on a web page needed JavaScript: dots under a carousel, a modal that fades out, a textarea that grows, an accordion that opens to its real height, and a button with properly smooth corners. Each one had a library, a snippet from a forum, or a hack with a made-up number in it.
In the last two years browsers have quietly added a CSS feature for every one of them. Support is not equal yet, so each demo below detects the feature and falls back sensibly. I built all five as free, editable snippets in the UI Snippets library. Open one, read the code, copy it.
The five at a glance
- Carousel dots and arrows from
::scroll-markerand::scroll-button. - Animated dialog and popover with
@starting-style. - Auto-growing textarea with
field-sizing: content. - Accordion that animates to height: auto with
interpolate-size. - Squircle corners with
corner-shape.
1. A carousel with no carousel code

A scroll container with scroll-snap-type was always a decent swipeable carousel. What it lacked was controls. Chrome 135 added two pseudo-elements that generate them: a ::scroll-marker dot for every slide, and ::scroll-button() arrows that scroll one page and disable themselves at the ends. The active dot is styled with :target-current, so you can stretch it into a pill with a transition.
.carousel { scroll-marker-group: after; scroll-snap-type: x mandatory; }
.slide::scroll-marker { content: ''; width: 12px; height: 12px; }
.slide::scroll-marker:target-current { width: 34px; }
.carousel::scroll-button(inline-end) { content: '→' / 'Next slide'; }
The text after the slash is the accessible name, so a screen reader says “Next slide” and not “right arrow”. In browsers without support the snippet reveals two ordinary buttons; the swiping works everywhere. Open the carousel snippet.
2. A dialog that fades out as well as in

A native <dialog> is display: none when closed, and you cannot transition from none. Two features fix both directions. @starting-style gives the element a first-frame look to animate from when it appears. transition-behavior: allow-discrete on display and overlay keeps it on screen until the fade-out ends.
dialog { opacity: 0; transform: scale(.96);
transition: opacity .28s, transform .28s,
overlay .28s allow-discrete, display .28s allow-discrete; }
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: scale(.96); } }
You keep everything the platform gives you for free: focus trapping, Escape to close, an inert page behind. The same recipe animates a popover menu, and the demo anchors it under its button. Open the dialog snippet.
3. A textarea that grows by itself

Every chat box and AI prompt field starts at one line and grows. The old fix reset the height and copied scrollHeight on every keystroke. Now it is one declaration, and lh units cap it in lines instead of pixels.
textarea { field-sizing: content; min-height: 1lh; max-height: 9lh; }
That is the whole feature. The snippet wraps it in a message composer where Enter sends, Shift+Enter adds a line, and a Firefox fallback copies scrollHeight because Firefox has not shipped it yet. Open the textarea snippet.
4. An accordion that opens to its real height

“How do I animate height: auto” has been asked for fifteen years, and the answers were all workarounds. interpolate-size: allow-keywords lets the browser interpolate between 0 and auto, and ::details-content exposes the part of a <details> that collapses. Give several <details> the same name and they become an exclusive accordion without a click handler.
:root { interpolate-size: allow-keywords; }
details::details-content { block-size: 0; transition: block-size .35s, content-visibility .35s allow-discrete; }
details[open]::details-content { block-size: auto; }
It works in Chrome and Edge now; elsewhere the items still open and close, just without the animation. The answers stay plain text in the HTML, which suits an FAQ page. Open the accordion snippet.
5. Squircle corners in one property

A border-radius joins a circular arc to a flat edge, and your eye can pick out where. A squircle, the shape of an app icon, eases the curve into the edge. Designers faked it with SVG masks, which also cut off shadows and focus rings. corner-shape changes the border box itself, so shadows and outlines follow.
.card { border-radius: 48px; corner-shape: squircle; }
It is new (Chrome and Edge 139), and unsupported browsers just keep the normal rounded corner, so it is a safe upgrade. The demo has a slider so you can see the difference between the two curves grow as the radius grows. Open the squircle snippet.
How to use them safely
- Detect, do not assume.
CSS.supports()and@supportstell you what the browser understands. Every snippet here uses one. - Make the fallback acceptable. A carousel without arrows still swipes, an accordion without animation still opens, a squircle without support is a rounded corner.
- Keep the native behaviour. Dialog focus trapping, details semantics and button names are what you get from the platform. Do not rebuild them.
- Respect reduced motion. All five turn their transitions off under
prefers-reduced-motion.
Frequently asked questions
Are these safe to use in production today?
Yes, as progressive enhancements. Each feature degrades to something that still works: swipe without arrows, instant open and close, a normal rounded corner. Do not rely on them for anything a visitor must see, only for polish.
Which browsers support them?
Chrome and Edge support all five at the versions mentioned above. @starting-style and dialog transitions also work in Safari and recent Firefox, field-sizing is in Safari but not Firefox yet, and the rest are Chromium first. Check the support note inside each demo.
Can I copy the code for client work?
Yes. Every snippet shows its HTML, CSS and JavaScript, which you can copy, edit and use in your own and your clients’ projects, and each has an AI prompt if you would like an assistant to adapt it.
Try them in the browser: carousel, dialog and popover, textarea, accordion and squircle corners.
Discover more from WebDevPuneet
Subscribe to get the latest posts sent to your email.




