Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

W3.CSS Tooltips

Share

W3.CSS Tooltip Classes

Tooltips display extra information when the user hovers over an element.

W3.CSS provides the following tooltip classes:

Class Defines
w3-tooltip The tooltip container
w3-text The tooltip content

Hover over the examples below:

London (9 million inhabitants) is the capital of England.

London 9 million inhabitants is the capital of England.


Tooltip Container and Text

The w3-tooltip class defines the element the user hovers over.

The w3-text class defines the content that appears on hover.

Hover over the sentence below:

London (9 million inhabitants) is the capital of England.

Example

<p class="w3-tooltip">London
  <span class="w3-text">(<em>9 million inhabitants</em>)</span>
  is the capital of England.
</p>
Try It Yourself »

Tooltip as a Tag

Add w3-tag to style the tooltip content as a tag:

London 9 million inhabitants is the capital of England.

Example

<p class="w3-tooltip">London
  <span class="w3-text w3-tag"><b>9 million inhabitants</b></span>
  is the capital of England.
</p>
Try It Yourself »

Image Tooltip

A tooltip can also contain text related to an image:

Car

A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars typically have four wheels.(Wikipedia)

A car is a wheeled, self-powered motor vehicle used for transportation. Most definitions of the term specify that cars typically have four wheels.(Wikipedia)

Car

Examples

<div class="w3-tooltip">
  <img src="img_car.jpg" alt="Car">
  <p class="w3-text">A car is a...</p>
</div>
Try It Yourself »
<div class="w3-tooltip">
  <p class="w3-text">A car is a...</p>
  <img src="img_car.jpg" alt="Car">
</div>
Try It Yourself »


Positioned Tooltip

Use CSS positioning when you want the tooltip content to appear in a specific position:

London 9 million inhabitants is the capital of England.

Example

<p class="w3-tooltip">London
  <span class="w3-text w3-tag"
  style="position:absolute;left:0;bottom:18px">
    9 million inhabitants
  </span>
  is the capital of England.
</p>
Try It Yourself »

Colored Tooltip

Add a W3.CSS color class such as w3-red:

Example

<span class="w3-text w3-tag w3-red">9 million inhabitants</span>
Try It Yourself »

Rounded Tooltip

Add a round class such as w3-round-xlarge:

Example

<span class="w3-text w3-tag w3-round-xlarge">9 million inhabitants</span>
Try It Yourself »

Tooltip Sizes

Use W3.CSS size classes to change the size of a tooltip.

Small Tooltip

Example

<span class="w3-text w3-tag w3-small">9 million inhabitants</span>
Try It Yourself »

Tiny Tooltip

Example

<span class="w3-text w3-tag w3-tiny">9 million inhabitants</span>
Try It Yourself »

Large Tooltip

Example

<span class="w3-text w3-tag w3-xlarge">9 million inhabitants</span>
Try It Yourself »

Animated Tooltip

Add w3-animate-opacity to fade in the tooltip content:

Example

<span class="w3-text w3-tag w3-animate-opacity">9 million inhabitants</span>
Try It Yourself »

Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.