Native details FAQ
InteractionA practical FAQ built from native disclosure controls that work without JavaScript.
HTML + CSS · No JavaScript
<details><summary>Question</summary>…</details> Interaction · Complete runnable example
Offer extra context without hiding essential instructions or moving focus into a popup.
This preview runs in an isolated document. Clipboard writes and saved preferences may be blocked, and printing requires the standalone file. A dialog affects only the example. Reset reloads the original example state.
Use a tooltip for short supplemental text. Important instructions remain on the page, and the tooltip contains no links, buttons, fields, or other focusable content.
The preview, copied text, and downloaded file use this same document.
<!doctype html>
<!--
MIT License
Copyright (c) 2026 MRHTML
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
http-equiv="Content-Security-Policy"
content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; img-src data: blob:; connect-src 'none'; form-action 'none'; object-src 'none'; base-uri 'none'"
/>
<title>MRHTML | A helpful little aside.</title>
<style>
:root {
font-family: Arial, Helvetica, sans-serif;
color-scheme: light;
--ink: #192f34;
--muted: #56666a;
--paper: #f6f5f0;
--line: #cdd5d0;
--accent: #186354;
--soft: #e7efe5;
--mono: Consolas, 'Liberation Mono', monospace;
}
* {
box-sizing: border-box;
}
html {
scroll-padding-top: 90px;
}
body {
margin: 0;
background: var(--paper);
color: var(--ink);
line-height: 1.6;
}
h1,
h2,
h3,
p {
margin: 0;
}
h1,
h2,
h3 {
font-weight: 500;
letter-spacing: -0.045em;
line-height: 1.1;
}
h1 {
font-size: clamp(38px, 5.5vw, 65px);
}
h2 {
font-size: 29px;
}
h3 {
font-size: 21px;
}
p {
overflow-wrap: anywhere;
}
a {
color: var(--accent);
text-underline-offset: 4px;
}
button,
select {
font: inherit;
color: inherit;
}
button {
cursor: pointer;
}
button,
a,
summary {
touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
outline: 3px solid #a94823;
outline-offset: 4px;
}
[hidden] {
display: none !important;
}
.wrap {
width: min(1050px, calc(100% - 64px));
margin-inline: auto;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
padding: 28px 0;
border-bottom: 1px solid var(--line);
}
.brand {
font-size: 15px;
font-weight: 700;
display: flex;
align-items: center;
gap: 10px;
letter-spacing: -0.5px;
}
.mark {
display: grid;
place-items: center;
width: 28px;
height: 28px;
background: var(--accent);
color: #fff;
font-weight: bold;
font-size: 18px;
}
.header > p,
.eyebrow,
.small {
font: 10px/1.7 var(--mono);
letter-spacing: 0.03em;
}
.header > p {
color: var(--muted);
}
main {
padding-block: 43px 50px;
}
.intro {
margin-bottom: 30px;
max-width: 720px;
}
.eyebrow {
color: var(--accent);
margin-bottom: 13px;
}
.intro > p:last-child {
font-size: 15px;
max-width: 570px;
color: var(--muted);
margin-top: 18px;
}
.surface {
background: #fff;
border: 1px solid var(--line);
border-radius: 14px;
box-shadow: 0 12px 32px #263e3010;
}
.button {
border: 1px solid var(--accent);
background: var(--accent);
color: #fff;
padding: 10px 16px;
min-height: 43px;
border-radius: 7px;
font-size: 13px;
font-weight: 600;
}
.button.secondary {
background: #fff;
color: var(--accent);
border-color: #a9bbb0;
}
.button[aria-disabled='true'],
button:disabled {
background: #edf0e9;
color: #5d695f;
border-color: #c9d1c4;
cursor: default;
}
.status {
font-size: 12px;
color: var(--muted);
min-height: 22px;
}
.note {
font-size: 12px;
color: var(--muted);
margin-top: 20px;
max-width: 75ch;
}
.footer {
display: flex;
justify-content: space-between;
gap: 20px;
padding-block: 22px;
border-top: 1px solid var(--line);
font-size: 10px;
color: var(--muted);
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
noscript p {
padding: 15px;
background: #e8ece2;
border-left: 3px solid var(--accent);
font-size: 13px;
margin-bottom: 20px;
}
code,
kbd {
font: 12px var(--mono);
}
kbd {
border: 1px solid #bcc7bd;
border-radius: 4px;
padding: 2px 5px;
background: #fff;
}
button:disabled:focus {
outline: none;
}
@media (max-width: 600px) {
.wrap {
width: calc(100% - 36px);
}
.header {
padding-block: 22px;
}
.header > p {
font-size: 8px;
max-width: 105px;
text-align: right;
}
.brand {
font-size: 13px;
gap: 8px;
}
main {
padding-block: 30px 35px;
}
.intro {
margin-bottom: 26px;
}
.intro > p:last-child {
font-size: 14px;
}
.eyebrow {
font-size: 9px;
}
h1 {
font-size: 40px;
}
.footer {
flex-wrap: wrap;
font-size: 9px;
}
}
@media (max-width: 350px) {
h1 {
font-size: 35px;
}
.button {
padding: 10px 12px;
font-size: 12px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation: none !important;
transition: none !important;
scroll-behavior: auto !important;
}
}
.settings {
overflow: visible;
}
.settings-title {
padding: 30px;
background: #e6ecdf;
border-radius: 13px 13px 0 0;
border-bottom: 1px solid #c6d1bd;
}
.settings-title .small {
font-size: 9px;
color: #4c6342;
}
.settings-title h2 {
font-size: 31px;
margin-top: 11px;
}
.settings-title p {
font-size: 13px;
color: #506249;
margin-top: 13px;
}
.setting-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 25px;
padding: 28px 30px;
border-bottom: 1px solid #dce3d5;
}
.setting-row:last-child {
border-bottom: 0;
}
.setting-row h3 {
font-size: 22px;
display: flex;
align-items: center;
gap: 10px;
}
.setting-row p {
font-size: 13px;
color: var(--muted);
margin-top: 10px;
max-width: 55ch;
}
.setting-label {
white-space: nowrap;
border: 1px solid #bac8b1;
border-radius: 20px;
padding: 4px 10px;
font: 9px var(--mono);
color: #4f6744;
}
.tip-trigger {
width: 29px;
height: 29px;
border-radius: 50%;
border: 1px solid #809675;
color: #3b5b31;
background: #f5f8ef;
font-size: 13px;
display: inline-grid;
place-items: center;
padding: 0;
flex-shrink: 0;
}
.tooltip {
position: fixed;
z-index: 20;
max-width: min(280px, calc(100vw - 24px));
padding: 14px 17px;
background: #213d2c;
color: #fff;
border: 1px solid #213d2c;
border-radius: 8px;
box-shadow: 0 8px 24px #192d2230;
font-size: 12px;
line-height: 1.65;
overflow-wrap: anywhere;
}
.tooltip::before {
content: '';
position: absolute;
inset: -10px;
z-index: -1;
}
.static-help {
padding-left: 12px;
border-left: 2px solid #879b70;
}
@media (max-width: 600px) {
.settings-title {
padding: 24px;
}
.settings-title h2 {
font-size: 27px;
}
.settings-title p {
font-size: 12px;
}
.setting-row {
padding: 25px 22px;
align-items: flex-start;
gap: 16px;
flex-direction: column;
}
.setting-row h3 {
font-size: 22px;
}
.setting-row p {
font-size: 12px;
}
.setting-label {
font-size: 8px;
}
.tip-trigger {
width: 44px;
height: 44px;
}
}
</style>
</head>
<body>
<header class="header wrap">
<span class="brand"
><span class="mark" aria-hidden="true">m.</span>MRHTML / Workshop</span
>
<p>SMALL PATTERNS.<br />CONSIDERED DETAILS.</p>
</header>
<main class="wrap">
<div class="intro">
<p class="eyebrow">08 / DISMISSIBLE TOOLTIP</p>
<h1>A helpful little aside.</h1>
<p>
Supplemental explanations that appear on hover or focus, stay open
while you move onto them, and dismiss with Escape.
</p>
</div>
<noscript
><p>
All supplemental explanations are printed beside the topics.
JavaScript adds the focus and hover tooltips.
</p></noscript
>
<section class="surface settings" aria-labelledby="settings-title">
<div class="settings-title">
<span class="small">WORKSHOP NOTEBOOK</span>
<h2 id="settings-title">Clear about the details.</h2>
<p>These are descriptions of this example, not account settings.</p>
</div>
<div class="setting-row">
<div>
<h3>
Local demonstration
<button
class="tip-trigger"
type="button"
id="help-local"
aria-label="About this local demonstration"
aria-describedby="tip-local"
hidden
>
?
</button>
</h3>
<p>Everything shown here stays in this document.</p>
<p class="static-help">
No account or submission service is connected to this example.
</p>
</div>
<span class="setting-label">LOCAL</span>
</div>
<div class="setting-row">
<div>
<h3>
Temporary state
<button
class="tip-trigger"
type="button"
id="help-state"
aria-label="About temporary state"
aria-describedby="tip-state"
hidden
>
?
</button>
</h3>
<p>There is no saved preference to manage.</p>
<p class="static-help">
Reloading starts the example again. No browser storage is used.
</p>
</div>
<span class="setting-label">THIS VISIT</span>
</div>
<div class="setting-row">
<div>
<h3>
Plain explanations
<button
class="tip-trigger"
type="button"
id="help-text"
aria-label="About plain explanations"
aria-describedby="tip-text"
hidden
>
?
</button>
</h3>
<p>Help text never contains a button or a link.</p>
<p class="static-help">
Keep essential instructions on the page. A tooltip should add
context, not hide a required step.
</p>
</div>
<span class="setting-label">JUST TEXT</span>
</div>
</section>
<div class="tooltip" id="tip-local" role="tooltip" hidden>
No account or submission service is connected to this example.
</div>
<div class="tooltip" id="tip-state" role="tooltip" hidden>
Reloading starts the example again. No browser storage is used.
</div>
<div class="tooltip" id="tip-text" role="tooltip" hidden>
Keep essential instructions on the page. A tooltip should add context,
not hide a required step.
</div>
<p class="note">
Tab to a question mark or hover over it. Move onto the explanation
without closing it. Escape dismisses it while focus stays in place. Tap
the question mark to toggle it on touch screens.
</p>
</main>
<footer class="footer wrap">
<span>MRHTML / Original runnable example</span
><span>Local content. No network required.</span>
</footer>
<script>
(() => {
'use strict';
const states = [...document.querySelectorAll('.tip-trigger')].map(
(button) => ({
button,
tip: document.getElementById(
button.getAttribute('aria-describedby'),
),
focused: false,
hovered: false,
tipHovered: false,
dismissed: false,
timer: 0,
pointerVisible: false,
}),
);
function place(state) {
if (state.tip.hidden) return;
const rect = state.button.getBoundingClientRect();
const width = state.tip.offsetWidth,
height = state.tip.offsetHeight;
const x = Math.max(
12,
Math.min(
innerWidth - width - 12,
rect.left + rect.width / 2 - width / 2,
),
);
let y = rect.top - height - 9;
if (y < 12) y = rect.bottom + 9;
y = Math.max(12, Math.min(innerHeight - height - 12, y));
state.tip.style.left = x + 'px';
state.tip.style.top = y + 'px';
}
function sync(state) {
clearTimeout(state.timer);
if (!state.focused && !state.hovered && !state.tipHovered) {
state.dismissed = false;
state.tip.hidden = true;
return;
}
state.tip.hidden = state.dismissed;
if (!state.tip.hidden) place(state);
}
function leave(state) {
clearTimeout(state.timer);
state.timer = setTimeout(() => sync(state), 160);
}
states.forEach((state) => {
state.button.addEventListener('focus', () => {
if (!state.focused && !state.hovered && !state.tipHovered)
state.dismissed = false;
state.focused = true;
sync(state);
});
state.button.addEventListener('blur', () => {
state.focused = false;
leave(state);
});
state.button.addEventListener('pointerenter', (event) => {
if (event.pointerType === 'touch') return;
if (!state.focused && !state.hovered && !state.tipHovered)
state.dismissed = false;
state.hovered = true;
sync(state);
});
state.button.addEventListener('pointerleave', () => {
state.hovered = false;
leave(state);
});
state.tip.addEventListener('pointerenter', () => {
state.tipHovered = true;
sync(state);
});
state.tip.addEventListener('pointerleave', () => {
state.tipHovered = false;
leave(state);
});
state.button.addEventListener('pointerdown', () => {
state.pointerVisible = !state.tip.hidden;
});
state.button.addEventListener('click', (event) => {
state.dismissed =
event.detail === 0 ? !state.tip.hidden : state.pointerVisible;
sync(state);
});
state.button.hidden = false;
});
document.addEventListener('keydown', (event) => {
if (event.key === 'Escape')
states.forEach((state) => {
if (!state.tip.hidden) {
state.dismissed = true;
state.tip.hidden = true;
}
});
});
let frame = 0;
function reposition() {
cancelAnimationFrame(frame);
frame = requestAnimationFrame(() => states.forEach(place));
}
window.addEventListener('resize', reposition);
window.addEventListener('scroll', reposition, { passive: true });
document.querySelectorAll('.static-help').forEach((text) => {
text.hidden = true;
});
})();
</script>
</body>
</html>