The <details> and <summary> pair is a known workhorse: the two elements give you a disclosure widget that responds to touch, mouse and keyboard without any scripting. Accordions are the canonical use, and the same markup can even play and pause an animated GIF.
But the widget-shaped cases aren't the only ones worth exploring. Two ideas push the elements further: footnotes and tooltips.
Why footnotes don't work
On the web today, footnotes are usually links. Clicking a marker in the paragraph moves you to the bottom of the page and back, using ID references in both directions. jQuery plugins such as BigFoot take accessible markup, strip away the link scaffolding and render the note as an inline button and tooltip instead.
That inline experience is the appeal. Could <details> and <summary> replace the plugin and the link hopping? No. If you try to nest either element inside a <p>, browsers render it outside the paragraph. That rules out the inline placement footnotes need, which is frustrating when replacing all those links is exactly the goal.
Tooltips as a working substitute
Tooltips, on the other hand, work well. Take markup that expands the date shown — a standard details/summary pair — and style it.
Start with the <details> element:
details {
border-radius: 3px;
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.15s background linear;
}
details:hover,
details:focus {
background: #d4d1ec;
}
Absolute positioning lets the tooltip's content sit relative to its trigger, and the background makes the widget read more like a button on click. Next, remove the default arrow the summary element renders:
summary {
background: url("https://assets.codepen.io/14179/Info.svg") 11px 11.5px no-repeat;
list-style: none;
padding: 10px;
padding-left: 33px;
}
Finally, absolutely position the paragraph inside <details> and draw a small upward triangle pointing back at the trigger:
details p {
cursor: auto;
background: #eee;
padding: 15px;
width: 250px;
position: absolute;
left: 0;
top: 35px;
border-radius: 4px;
right: 0;
}
// Tiny triangle that points up
details p:before {
content: "";
border-bottom: 12px solid #eee;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
height: 0;
left: 10px;
position: absolute;
top: -10px;
width: 0;
}
Clicking the tooltip reveals the description beneath it. The result is a working disclosure without a line of JavaScript.
Animation and outside clicks
A short animation on open adds polish:
details[open] p {
animation: animateDown 0.2s linear forwards;
}
@keyframes animateDown {
0% {
opacity: 0;
transform: translatey(-15px);
}
100% {
opacity: 1;
transform: translatey(0);
}
}
Clicking the tooltip now pops it open, and it also opens by tabbing to it and pressing space.
Light touches can extend this further. One thing you probably don't want is tooltips opening all over the page; documents that use them heavily get clumsy and visually distracting. Closing the open tooltip when the user clicks outside it needs only a little JavaScript:
const tooltip = document.querySelector(".tooltip");
document.addEventListener("click", function (e) {
var insideTooltip = tooltip.contains(e.target);
if (!insideTooltip) {
tooltip.removeAttribute("open");
}
});
With that in place, clicking off the tooltip dismisses it.
Another approach to animating the element
Animation is worth pursuing on its own. A dedicated write-up covers animating the details element with WAAPI (the Web Animations API), rather than the CSS transition sketched above.
There are other directions in this space as well: building a details element that opens but never closes, and using <details> for menus and dialogs as a progressive enhancement. The two elements can't do everything, but they handle a surprising amount of the work — and more uses remain to be found.



