Four ways to build a tooltip with modern CSS and JavaScript Bryntum published a guide detailing four methods to build a tooltip using modern CSS and JavaScript: the HTML title attribute, a CSS-only tooltip drawn with pseudo-elements, an HTML popover placed with CSS anchor positioning, and the Bryntum Tooltip widget. The guide notes that the HTML title attribute cannot be styled, is controlled by the browser's show delay, generally does not appear on keyboard focus, and does not show on touch devices, while the CSS-only approach uses a data-tooltip attribute and a ::after pseudo-element with content: attr(data-tooltip) and shows on :hover and :focus-visible. The article states that newer web features such as the popover HTML attribute and CSS anchor positioning allow tooltip placement without JavaScript, which previously required positioning libraries like Floating UI. Four ways to build a tooltip with modern CSS and JavaScript We strive to keep posts updated, but code samples may sometimes be outdated. Humans, see the Bryntum documentation https://bryntum.com/docs/ ; agents, https://mcp.bryntum.com https://mcp.bryntum.com for the latest info. A tooltip is a common UI element: it’s the little bubble of supplementary text that appears when the user hovers over or focuses an element. Showing a tooltip on hover should take a few lines of CSS. It does, until an overflow: hidden element clips the bubble, a trigger near the screen edge pushes the tooltip out of view, or a hidden tooltip quietly adds a horizontal scrollbar to the page. Detecting and fixing those collisions used to require JavaScript, which is why positioning libraries like Floating UI exist. Newer web features, like the popover HTML attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global attributes/popover and CSS anchor positioning https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Anchor positioning/Using , let you do this without JavaScript. In this guide, we’ll show you how to build a tooltip in four different ways, from a simple HTML attribute to a full JavaScript tooltip component with async data loading: 1. The HTML title attribute 2. A CSS-only tooltip drawn with pseudo-elements 3. An HTML popover placed with CSS anchor positioning 4. The Bryntum Tooltip widget Each approach builds on the previous one. The HTML title attribute The original HTML tooltip needs no CSS or JavaScript at all. Every HTML element accepts a title attribute https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global attributes/title , and the browser renders its value as a tooltip: