I'm currently adding verbose tooltips to our site, and I'd like (without having to resort to a whizz-bang jQuery plugin, I know there are many!) to use carriage returns to format the tooltip.
To add the tip I'm using the title
attribute. I've looked around the usual sites and using the basic template of:
<a title='Tool?Tip?On?New?Line'>link with tip</a>
I've tried replacing the ?
with:
<br />
&013; /
\r\n
Environment.NewLine
(I'm using C#)
None of the above works. Is it possible?
Much nicer looking tooltips can be created manually, and can include HTML formatting.
This is taken from the w3schools post on this. Experiment with the above code here.
use
data-html="true"
and apply<br>
.As of Firefox 12 they now support line breaks using the line feed HTML entity:
This works in IE and is the correct according to the HTML5 spec for the title attribute.
Tested this in IE, Chrome, Safari, Firefox (latest versions 2012-11-27):
Works in all of them...
From the information available on accessibility and the use of tooltips making them larger with the use of CR or line break is appreciated, the fact that the various browsers cannot/will not agree on basics shows that they don't much care about accessibility.
Razor Syntax
In the case of ASP.NET MVC you can just store the title as a variable as use
\r\n
and it'll work.