Bootstrap Tooltips
Small hints, better experiences. Learn to add helpful hover and focus messages to buttons, links, and interface elements using Bootstrap.
<button class="btn btn-primary" data-bs-toggle="tooltip" data-bs-title="Helpful hint!"> Hover Me </button>
What Is a Bootstrap Tooltip?
A tooltip is a short message that appears when someone hovers over or focuses on an element. It provides extra information without filling the page with additional text.
Tooltips are commonly used for icon explanations, button descriptions, shortcuts, and brief hints. Bootstrap provides the styling, positioning, and interactive behavior.
Create Your First Tooltip
Start with an ordinary Bootstrap button. Add
data-bs-toggle="tooltip" to identify
the element as a tooltip trigger, and
data-bs-title to supply its message.
<button type="button"
class="btn btn-primary"
data-bs-toggle="tooltip"
data-bs-title="Click to save your changes">
Save
</button>
data-bs-toggle="tooltip"
Marks the element as a Bootstrap tooltip trigger.
data-bs-title
Supplies the text displayed inside the tooltip.
Unlike Bootstrap dropdowns, tooltips are not activated automatically just by adding HTML attributes. They must be initialized with JavaScript.
Make Your Tooltips Work
First, include Bootstrap’s CSS and JavaScript bundle. Then initialize every element marked as a tooltip. The bundle includes Popper, which Bootstrap uses for tooltip positioning.
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script>
const triggers =
document.querySelectorAll('[data-bs-toggle="tooltip"]');
triggers.forEach(element => {
new bootstrap.Tooltip(element);
});
</script>
Choose Where the Tooltip Appears
Bootstrap supports four tooltip placements:
top, bottom, start, and end.
Use data-bs-placement to select one.
topDisplays the tooltip above its trigger.bottomDisplays the tooltip below its trigger.startDisplays the tooltip on the starting side.endDisplays the tooltip on the ending side.<button type="button"
class="btn btn-success"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
data-bs-title="This appears below the button">
Bottom Tooltip
</button>
Bootstrap may adjust a tooltip’s placement when there isn’t enough space, helping prevent it from being cut off by the viewport.
Write Helpful Tooltip Text
A tooltip should explain an action or provide useful context. For example, a button labeled “Export” might display a message explaining the file format.
<button type="button"
class="btn btn-outline-primary"
data-bs-toggle="tooltip"
data-bs-title="Download your report as a PDF">
Export
</button>
Prefer clear, concise text. Avoid placing important instructions or essential information only inside tooltips, because not every user can easily discover or interact with them.
Support Keyboard and Touch Users
Bootstrap tooltips can appear when a user focuses on a button or link using the keyboard. This is why it’s important to use accessible, focusable elements as triggers.
<button type="button"
class="btn btn-secondary"
data-bs-toggle="tooltip"
data-bs-trigger="hover focus"
data-bs-title="Open your account settings">
Settings
</button>
Control How Tooltips Behave
Bootstrap also supports options such as
data-bs-trigger and
data-bs-custom-class.
These allow you to change when tooltips appear
and customize their visual appearance.
<button type="button"
class="btn btn-dark"
data-bs-toggle="tooltip"
data-bs-trigger="click"
data-bs-title="Click again to hide this hint">
Click for Hint
</button>
The click trigger can be useful
when a tooltip needs to appear after a deliberate
action. For ordinary explanatory hints, hover
and focus behavior is generally more familiar.
🚀 mC0de Challenge
Build a Helpful Action Toolbar
Imagine you’re building a document editor. Your toolbar has several buttons, and you want to help users understand what each action does.
Your mission: Complete all five tasks in the Sandbox below.
Check off each task as you finish. You can load the sample solution to compare your results.
mC0de Bootstrap Sandbox
Edit the HTML, run your code, and hover over or focus on the buttons to reveal tooltips.
✓ What You've Learned
- Tooltips display short contextual messages when users interact with an element.
data-bs-toggle="tooltip"identifies a Bootstrap tooltip trigger.data-bs-titledefines the tooltip message.- Tooltips must be initialized using Bootstrap JavaScript.
data-bs-placementcontrols top, bottom, start, or end positioning.data-bs-triggercontrols how a tooltip is activated.- Focusable buttons and links make tooltip interaction more accessible.
- Tooltips should provide supplementary hints, not essential instructions.
Up next: We'll explore Bootstrap List Design and learn to create attractive, structured list groups.
Nice Work! 🎉
You've learned how to create Bootstrap tooltips, customize their messages and positions, and make helpful hints available through keyboard focus. Ready to record your progress?


