A dropdown, a dialog and tabs with no JavaScript
For close to ten years I've carried the same CSS between projects, most of them server-rendered: Django, Rails, Laravel, htmx. And I kept seeing the same thing. The backend was fine, the pages were fine, and then the app pulled in a JavaScript library for three things: a dropdown, a modal and tabs.
Browsers do all three now, and I rebuilt my CSS around them this year. Here's the HTML for each, what it needs from the browser, and where it still falls short.
A dropdown
<button type="button" popovertarget="account">Account</button>
<div id="account" popover>
<a href="#">Profile</a>
<a href="#">Sign out</a>
</div> That's it. The button opens it, the button again closes it, and so do Esc and a click anywhere else. Only one of these menus is open at a time. It sits in the top layer, so a parent with overflow: hidden or a sticky header can't clip it.
The part that took longest was placing it under its button. By default a popover opens in the middle of the screen. Anchor positioning fixes that:
.menu {
position-area: bottom span-right;
position-try-fallbacks: flip-inline, flip-block;
margin-top: 4px;
} The button that opens a popover is its anchor, so there's no anchor-name to wire up. When there's no room below, it flips up by itself. On a phone I don't anchor it at all. A media query turns it into a sheet at the bottom of the screen, because a menu hanging off a button near the edge of a 360px screen is just annoying.
Anchor positioning is the newest piece here. Check it against the browsers your users have.
A dialog
<button type="button" commandfor="invoice" command="show-modal">New invoice</button>
<dialog id="invoice" closedby="any">
<form method="post" action="invoices">
...
<button type="button" commandfor="invoice" command="close">Cancel</button>
<button type="submit">Send</button>
</form>
</dialog> commandfor and command are new, and they're the piece I waited for. Before them you needed a line of script to call showModal(). Now the button says which dialog and what to do. The page behind goes inert, focus moves into the dialog and comes back to the button when it closes. closedby="any" lets a click outside close it, and Esc already does.
The form inside is a normal form. It posts to your server like any other, and your server answers with the next page. If you only want to close it, use method="dialog" and submitting closes the dialog instead.
The catch is support. commandfor needs Chrome and Edge 135, Firefox 144 or Safari 26.2. On anything older the button does nothing, so if your users are on old browsers this one isn't ready for you. closedby comes to Safari in 27.3; before that, Esc and your Cancel button still work.
Tabs
<div class="tabs">
<div>
<label class="tab"><input type="radio" name="status" value="all" checked> All</label>
<label class="tab"><input type="radio" name="status" value="overdue"> Overdue</label>
</div>
<div class="panel">All the invoices</div>
<div class="panel">Only the overdue ones</div>
</div> Radio buttons. Picking one unpicks the others, and the arrow keys move between them for free. The CSS shows the panel that matches the picked radio:
.tabs > .panel { display: none; }
.tabs:has(.tab:nth-child(1) input:checked) > .panel:nth-child(2),
.tabs:has(.tab:nth-child(2) input:checked) > .panel:nth-child(3) {
display: block;
} Since they're real radios, the picked tab is form data. Put the tabs in a GET form and the server knows which one is open, and can render the next page with the same tab checked.
What you lose: picking a tab doesn't change the URL, so you can't link someone to the Overdue tab. And a screen reader hears a group of radio buttons, not a tab list. That's honest about what they are, but it isn't the same thing.
The rest
An accordion is <details>, and giving several the same name means only one stays open. A tooltip is a span that shows on :hover and :focus-visible. A toast is a popover="manual", so a click elsewhere doesn't close it. That one does need a line of script if it should appear after something happens, because there's no attribute to render a popover already open.
What I got out of it
There's nothing to load before a menu works, nothing to initialise, and nothing to re-initialise when htmx or Turbo swaps part of the page, since the browser already knows what a popover is. The server sends HTML and the HTML works.
All of this is in one file you can open, use with JavaScript turned off, and read the source of: alloyhtml.com/example.html. The styles there are Alloy, which I made and which is free and MIT. None of the behaviour comes from it. The browser does that part.