TipsBlocks Web Technique Library

PRACTICAL WEB TIP

← Back to library

Accessible Help Tooltip

An accessible help tooltip appears when its icon is hovered or focused.

Live Demo

Hover over the element or use Tab to focus.

Source Code

Copy the HTML, CSS or JavaScript you need for your project.

HTML
<div class="tbx-1048"><span class="tbx-1048__label">Visibility</span><button type="button" aria-describedby="tbx-1048-description">?</button><span class="tbx-1048__bubble" aria-hidden="true">You can change these settings later.</span><span id="tbx-1048-description" class="tbx-1048__sr">You can change these settings later.</span></div>
CSS
.tbx-1048{position:relative;display:inline-flex;align-items:center;gap:9px;padding:45px 20px;color:#263c4d;font-family:system-ui}
.tbx-1048__label{font-size:13px;font-weight:700}.tbx-1048 button{width:23px;height:23px;padding:0;display:grid;place-items:center;border:1px solid #90aab9;background:#eff5f7;border-radius:50%;color:#2e6476;font-size:12px;font-weight:800;cursor:help;transition:background .2s,transform .2s}
.tbx-1048__bubble{position:absolute;left:50%;bottom:80px;transform:translate(-50%,8px);max-width:260px;min-width:206px;padding:11px 13px;border-radius:7px;background:#23475b;color:#fff;text-align:center;font-size:11px;line-height:1.55;box-shadow:0 10px 22px #0c27392b;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .22s,transform .22s,visibility .22s}
.tbx-1048__bubble:after{content:"";position:absolute;left:50%;bottom:-6px;transform:translateX(-50%) rotate(45deg);width:12px;height:12px;background:#23475b}
.tbx-1048:has(button:is(:hover,:focus-visible)) .tbx-1048__bubble{opacity:1;visibility:visible;transform:translate(-50%,0)}
.tbx-1048 button:is(:hover,:focus-visible){background:#d9edf0;transform:scale(1.07)}.tbx-1048 button:focus-visible{outline:3px solid #d28a57;outline-offset:3px}
.tbx-1048__sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
@media(prefers-reduced-motion:reduce){.tbx-1048 button,.tbx-1048__bubble{transition:none}}

How to Use

Insert the HTML and add the CSS to your stylesheet. Adjust colors and sizes and avoid class conflicts.

Use Case

Useful for forms and help sections.

Technical Notes

Keep controls usable on touch devices. Test keyboard focus and reduced-motion preferences.

Mobile:Ensure the interactive content remains accessible without hover on touch devices.

Browser:Uses modern CSS. Check behavior in the browsers you support.

Reduced Motion:Check that prefers-reduced-motion is respected.