codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS tooltips

CSS tooltips

Text that appears on hover.

Position a hidden element next to the trigger and show it on hover or focus.

Example code

<style>
.t{position:relative;display:inline-block;margin:30px;border-bottom:1px dotted}
.t span{visibility:hidden;position:absolute;bottom:125%;left:0;background:#14213d;color:#fff;padding:5px 8px;white-space:nowrap}
.t:hover span,.t:focus span{visibility:visible}
</style>
<div class='t' tabindex='0'>Hover me<span>Tooltip text</span></div>

Run this code in the online editor

← CSS 3D transformsCSS image filters →