Basic Tooltip

Move the mouse over the text below:

Hover over me Tooltip text

/* Position the tooltip : Right Tooltip */ position: absolute; z-index: 1; top: -5px; left: 105%; /* Position the tooltip : Left Tooltip */ position: absolute; z-index: 1; top: -5px; right: 105%; /* Position the tooltip : Top Tooltip */ position: absolute; z-index: 1; bottom: 100%; left: 50%; margin-left: -60px; /* Use half of the width (120/2 = 60), to center the tooltip */ /* Position the tooltip : Bottom Tooltip */ position: absolute; z-index: 1; top: 100%; left: 50%; margin-left: -60px; /* Use half of the width (120/2 = 60), to center the tooltip */

Exported from Notepad++
<html><style> .tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; } .tooltip .tooltiptext { visibility: hidden; /* visible = display tooltip without hover */ width: 120px; background-color: pink; color: #000000; text-align: center; border-radius: 6px; border : 1px solid red; padding: 5px 0; /* Position the tooltip */ position: absolute; /*respect to tooltip position relative*/ z-index: 1; } .tooltip:hover .tooltiptext { visibility: visible; } </style> <body style="text-align:left;"> <h2>Basic Tooltip</h2> <p>Move the mouse over the text below:</p> <div class="tooltip">Hover over me <span class="tooltiptext">Tooltip text</span> </div> <p style ="visibility:hidden;"> /* Position the tooltip : Right Tooltip */ position: absolute; z-index: 1; top: -5px; left: 105%; /* Position the tooltip : Left Tooltip */ position: absolute; z-index: 1; top: -5px; right: 105%; /* Position the tooltip : Top Tooltip */ position: absolute; z-index: 1; bottom: 100%; left: 50%; margin-left: -60px; /* Use half of the width (120/2 = 60), to center the tooltip */ /* Position the tooltip : Bottom Tooltip */ position: absolute; z-index: 1; top: 100%; left: 50%; margin-left: -60px; /* Use half of the width (120/2 = 60), to center the tooltip */ </p> </body> </html>