A <details> element without styling looks like this:
<details>: The Details disclosure element
The details HTML element creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label must be provided using the summary element.
(read more on MDN)
Its appearance (a block element with a little arrow inside the summary element) is fairly consistent across browsers. That's about as far as it goes though.
Hiding the arrow
What you're supposed to do is
details > summary {
list-style: none;
}
details > summary::marker,
details > summary::-webkit-details-marker {
display: none;
}
we can't do that second part on cohost though!
So what if we change display and list-style of summary?
Click me
Very well?Depending on your browser you may already see the caveat - this works in Chromium and Firefox (even display: block is enough), but not Safari (which wants that -webkit-details-marker after all).
The size of the arrow depends on the size of the font, so we can just set that to 0, and set it back in a span element inside the summary:
Click me
Very well.And we probably want to indicate to the user that our now-regular-looking summary is interactive, so let's give it an underline:
Click me
Very well.And that's about it, but if you don't get an underline in Safari, you might have to separate text-decoration: underline dotted into text-decoration: underline; text-decoration-style: dotted.
Most interactive tricks that you'll see around here are variations of this formula - the summary is what you can click and the rest of the elements inside the details-element are what should appear/disappear.
🍎 take a bite
The elements can overlap (position: absolute), be click-through (pointer-events: none), push each other around (via flexboxes or even just float), and so on - inspect an element in your favorite CSS crime and you might find something new.
Inline disclosure
So you want a little clarification or a bit of trivia right in the middle of the text. You should be able to
just make details and summary inline
(by giving themdisplay:inline)details is a block element so it breaks the paragraph, but if we
make our own paragraph
(out of a DIV element, of course - it doesn't need much apart of `margin: 1.25em 0` to mimic the regular paragraphs)give it to details
(and don't give it to summary, because that renders the disclosure element non-interactive on Safari)A disclosure
(now open!)But still, good for trailing details in a paragraph, I suppose?
Inline block disclosure
make it seem
inline-flex container so that the entirety of the "title bar" remains clickable when it's open.
I wrote a generator for these.
Floating disclosure
tooltips
Conclusions
Fun element, isn't it?
For less-esoteric purposes you may also be interested in eevee's tutorial
prechoster source files for this post can be found on GitHub


