Skip to content

Instantly share code, notes, and snippets.

@tomhodgins
Last active May 30, 2020 23:27
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tomhodgins/5296100 to your computer and use it in GitHub Desktop.
Save tomhodgins/5296100 to your computer and use it in GitHub Desktop.
HTML inside Bootstrap tooltips
<!DOCTYPE html>
<html>
<head>
<title>Tooltip HTML Styles</title>
<!-- Bootstrap: with responsive, no icons -->
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<!-- FontAwesome -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<!-- Boostrap JavaScript -->
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
<!-- Source Sans via Google Web Fonts -->
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
</head>
<body>
<!-- HTML Section -->
<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="hero-unit">
<h1 style="text-align:center;">Tooltip HTML Styles</h1>
<h2>Default Bootstrap Tooltips, with HTML</h2>
<p>
<a href="#" data-toggle="tooltip" data-html="true" title="This is a regular Bootstrap tooltip<ul><li>item 1</li><li>item 2</li></ul>">I contain a &lt;ul&gt;</a>
</p>
<p>
<a href="#" data-toggle="tooltip" data-html="true" title="<img src='http://placehold.it/250/250'>">I contain an image</a>
</p>
</div>
</div>
</div>
<!-- JavaScript Section -->
<script type="text/javascript">
$(document).ready(function(){
$('a[data-toggle=tooltip]').tooltip();
});
</script>
<!-- CSS Section -->
<style>
* {
font-family: 'Source Sans Pro', sans-serif;
}
.hero-unit {
margin-top: 100px;
font-weight: 400;
}
</style>
</body>
</html>
@AjayDhande
Copy link

Just for highlighting the answer

data-html="true" is the required attribute to be able to use HTML in tooltip.

Copy link

ghost commented Jul 10, 2018

can i add class inside ul or li tag?

@ameer78
Copy link

ameer78 commented Dec 26, 2018

<3 <3

@poojashah19
Copy link

Is it possible to decode special characters like < in tooltip when bootstrap tooltip is enabled using data-html?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment