CSS tooltip
Text from a data attribute, shown on hover and focus.
CSS · CSS tooltipIntermediate
[data-tip] { position: relative; }
[data-tip]::after {
content: attr(data-tip);
position: absolute;
left: 50%;
bottom: calc(100% + 8px);
transform: translateX(-50%);
padding: 0.35rem 0.6rem;
border-radius: 6px;
background: #111827;
color: #fff;
font-size: 0.8rem;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 0.15s;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }tooltipdata attributehoverpseudo-element