Open In App

What is the use of data-toggle Attribute for Tooltips ?

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The data-toggle attribute for tooltips in Bootstrap is used to specify the trigger event that activates the tooltip. When applied to an HTML element, such as a button or link, this attribute defines the event (e.g., hover, click, focus, etc.) that causes the tooltip to appear.

Preview

Tooltip placements

Syntax

<button data-toggle="tooltip" title="Tooltip text">Hover me</button>

Explanation: By including the data-toggle="tooltip" attribute on an element, along with the title attribute specifying the tooltip text, Bootstrap enables the tooltip functionality for that element. The data-toggle="tooltip" attribute tells Bootstrap to activate the tooltip when the specified trigger event occurs (e.g., when the user hovers over the element). This allows developers to easily add interactive tooltips to elements in their web pages.

Features

  • Provides a simple and intuitive way to enable tooltip functionality on HTML elements.
  • Offers flexibility in specifying the trigger event (e.g., hover, click, focus) that activates the tooltip.
  • Enhances user experience by providing additional context or information when interacting with elements.
  • Easily customizable through Bootstrap’s options and JavaScript API, allowing developers to tailor tooltips to their specific requirements.
  • Supports accessibility standards, ensuring tooltips are usable and understandable for all users.

Ref: https://www.geeksforgeeks.org/bootstrap-tooltips/


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads