Skip to content

Accessible tooltips in HTML and CSS

Tooltips in four positions that open on hover, tap and keyboard focus, and close with Escape, as WCAG requires.

Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in HTML and CSS

index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Info-bulles accessibles</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <p class="ibl-hint">Survolez, touchez ou atteignez avec Tab les termes soulignés. La touche <kbd>Échap</kbd> referme l’info-bulle.</p>
      <article class="ibl-card" aria-labelledby="ibl-titre">
style.css
:root {
  --ibl-card-bg: #ffffff;
  --ibl-text: #1c2a39;
  --ibl-muted: #4b5563;
  --ibl-line: #e2e8f0;
  --ibl-total-bg: #f0fdfa;
  --ibl-accent: #0f766e;
  --ibl-focus: #0f766e;
  --ibl-tip-bg: #1e293b;
  --ibl-tip-text: #f8fafc;
  --ibl-tip-shadow: 0 10px 24px rgb(15 23 42 / 0.22);
  --ibl-kbd-bg: #ffffff;
tooltip.js
// Escape hides the bubble without moving focus or the pointer; it comes back on the next hover or focus.
const iblTips = [...document.querySelectorAll("[data-ibl]")];
const iblReset = (tip) => tip.removeAttribute("data-ibl-dismissed");

iblTips.forEach((tip) => {
  const trigger = tip.querySelector("button");
  // A tap does not always focus a button (Safari): the click opens the bubble too.
  trigger.addEventListener("click", () => {
    iblReset(tip);
    tip.setAttribute("data-ibl-open", "");
  });
  tip.addEventListener("pointerleave", () => {

Free component: copy it freely, including for commercial projects.

Breadcrumbs and pagination components in HTML and CSS
  • A bottom bar with Call, Directions and Free quote that tucks away while visitors read down the page and returns as soon as they scroll up. Built for tradespeople whose customers arrive on a phone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A slim bar at the top of the page with a message, a link and a close button; once closed, it stays hidden for the period you choose.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A sticky sidebar table of contents for blog posts: it highlights the section being read, shows the reading time left and folds into a list under the title on mobile.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A column of dots on the side of the page that follows the section being read and lets visitors jump to it, with a label on hover and focus.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An order step indicator: finished steps clickable to go back, the current step announced, upcoming steps locked.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Quick access links that appear on the first Tab press to skip the header and menu, as required by the RGAA and WCAG.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component