</> Code Corner

CSS · CSS Advanced · Lesson 51

CSS Tooltips

Show extra information on hover.

A tooltip is often used to give extra information when the user moves the mouse over an element.

Example

<style>
.tooltip { position: relative; display: inline-block; border-bottom: 1px dotted black; margin-top: 50px; font-family: Arial; }
.tooltip .tip {
  visibility: hidden; opacity: 0; transition: opacity .3s;
  width: 140px; background: #333; color: #fff; text-align: center; border-radius: 6px; padding: 6px;
  position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -70px;
}
.tooltip:hover .tip { visibility: visible; opacity: 1; }
</style>
<div class="tooltip">Hover over me
  <span class="tip">Tooltip text</span>
</div>

Keep reading “CSS Tooltips”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋