Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Explain Bootstrap Tooltip

  • Last Updated : 07 Oct, 2021

In Bootstrap Framework, Tooltip is a plugin that displays a small pop-up box when the user hovers the mouse pointer over an element. For example, when a user points over a link or buttons, etc. a small pop-up with a hint or information about the element is being hovered. This Tooltip Plugin is generally used when we want to display the purpose of each component on the webpage, just by moving the mouse pointer over the component.

To implement tooltip, we need to add the data-toggle=”tooltip” attribute to an element and the title attribute is used to display text on hover. We must initialize Tooltip to trigger, Tooltips via JavaScript by using the tooltip() method that specifying the id, class, or any CSS selector of the target element in the JavaScript code. In this article, we will learn about tooltip in Bootstrap along with its configuration & implementation. Please refer to the Bootstrap 4 | Tooltip article for further details.

Step to setup bootstrap tooltip plugin:

Include Bootstrap and jQuery CDN into the <head> tag

<link rel=”stylesheet” href=””>
<script src=””></script>
<script src=””></script>

Add Tooltip Markup in HTML element –

<a href="#" data-toggle="tooltip" 
    title="Some Information or Hint">
    Hover over me

Add jQuery to the <script> tag to Trigger the Tooltips –

    $(document).ready(function () {

Positioning Tooltips (optional) –

By default, the bootstrap tooltip plugin will always appear on top of the element. But we can use a data-placement attribute to change the position of the tooltip plugin so that we can position the tooltip on the top, bottom, left, or right side of the element.

<a href="#" data-toggle="tooltip" 
    title="Tooltip on top">
    Tooltip on top

<a href="#" data-toggle="tooltip" 
    title="Tooltip on bottom">
    Tooltip on bottom

<a href="#" data-toggle="tooltip" 
    title="Tooltip on left">
    Tooltip on left

<a href="#" data-toggle="tooltip" 
    title="Tooltip on right">
    Tooltip on right

We can also position Tooltips via JavaScript:

    $(document).ready(function () {

        //.tooltip-**** is the class 
        // specified in the html element
        $(".tooltip-top").tooltip({ placement: "top" });
        $(".tooltip-right").tooltip({ placement: "right" });
        $(".tooltip-bottom").tooltip({ placement: "bottom" });
        $(".tooltip-left").tooltip({ placement: "left" });

At this stage, we have successfully configured the tooltip to start work on it.



<!DOCTYPE html>
    <title>Bootstrap Tooltip Example</title>
    <meta charset="utf-8" />
    <meta name="viewport" content=
        "width=device-width, initial-scale=1" />
    <link rel="stylesheet" href=
    <div class="container">
        <h1 class="text-success">
        <h5>Bootstrap Tooltip Example</h5>
        <br />
        <a href="#" data-toggle="mytooltip" 
            title="A Computer Science portal for geeks">
            Hover me
        // Add below code to trigger tooltip
        $(document).ready(function () {


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!