How can I use a carriage return in a HTML tooltip?
It’s simple: just press Enter!
<a href="#" title='Tool
Tip
On
New
Line'>link with tip</a>
Add line break within tooltips
Just use the entity code
for a linebreak in a title attribute.
Break HTML tooltip message using line breaks
You're using the wrong slash - new line should be \n not /n:
tooltipData="Helo,Angular 2" + "
" + "This button is used to test hover message" + "\n" + "This message should come at the last"
Simple html and css tooltip with newline/carriage return
You can
EDIT: This corrects my previous answer that said you can't.
Because your CSS uses content: attr()
to get the text inside a specified attribute, you can use an HTML entity code such as
to insert a newline.
Inserting a newline via an HTML entity code:
Note: You must set display: block
and white-space: pre|pre-line|pre-wrap
for the newline to display.
[data-tooltip] { cursor: default; font: normal 1em sans-serif;}
[data-tooltip]:hover:after { display: inline-block; content: attr(data-tooltip); white-space: pre-wrap; color: Tomato; background-color: OldLace; padding: 1em;}
<span data-tooltip="Sentence one here. Sentence
two here. Sentence three here.">See my CSS tooltip with HTML-entity 
 line break:</span>
How can I use a carriage return in a HTML tooltip?
It’s simple: just press Enter!
<a href="#" title='Tool
Tip
On
New
Line'>link with tip</a>
Carriage Return tooltip text in a title tag using JS
Some browsers will allow
Others will not let you format the tool tip unless you use jQuery UI tooltip or similar
Live demo
The demo is using jQuery 1.6.4 and jQuery UI v1.11.0pre just to let you see that jQuery and jQuery UI can have different versions
the dynamic part is found here:
jQuery Tooltip UI - trigger tooltip after x seconds
var titles = {
"aprmay":"1. April: Result (49)<br/>2. May: Result (47)",
"junjul":"1. June: Result (50)<br/>2. July: Result (42)"
}
$(function() {
$(".result").each(function() {
var title = this.title.replace(/; /g,"<br/>");
$(this).tooltip({ "content": title });
});
// dynamic generate on hover
// https://stackoverflow.com/a/16523285/295783
$(document).tooltip({
items: '.dynresult',
show: 100,
hide: 500,
position: { my: 'center bottom', at: 'center top' },
content: function( callback ) {
var title = titles[this.id];
callback( title );
}
});
});
function getTitles(obj) {
return titles[obj.id];
}
using this HTML
<h3>Static titles</h3>
<a href="#" class="result" title="1. Apr: Result (45); 2. May: Result (45)">April/May</a>
<a href="#" class="result" title="1. June: Result (50); 2. July: Result (42)">June/July</a>
<hr/>
<h3>Dynamic titles</h3>
<a href="#" class="dynresult" title="" id="aprmay">April/May</a>
<a href="#" class="dynresult" title="" id="junjul">June/July</a>
How can I use a carriage return in a HTML tooltip?
It’s simple: just press Enter!
<a href="#" title='Tool
Tip
On
New
Line'>link with tip</a>
Related Topics
Equal Width Flex Items Even After They Wrap
How to Deal With Page Breaks When Printing a Large HTML Table
How to Force a Line Break in a Long Word in a Div
How to Expand Floated Child Div'S Height to Parent'S Height
Html/Css: Making Two Floating Divs the Same Height
Display Pdf Within Web Browser
The Reference to Entity "Foo" Must End With the ';' Delimiter
Twitter Bootstrap 3, Vertically Center Content
Why Is Vertical-Align: Middle Not Working on My Span or Div
How to Center Elements on the Last Row in CSS Grid
An Invalid Form Control With Name='' Is Not Focusable
Display: Inline-Block Extra Margin
"X-Ua-Compatible" Content="Ie=9; Ie=8; Ie=7; Ie=Edge"
Scraping Data from Website Using Vba
Play Local (Hard-Drive) Video File With Html5 Video Tag