views:

5625

answers:

6

Hi,

I'm currently adding verbose tooltips to our site, and I'd like (without having to resort to a whizz-bang jQuery plugin, I klnow 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; / &#13;
  • \r\n
  • Environment.NewLine (I'm using C#)

Neither work. Is it possible ??

WOW! Thanks all - 6 different answers in less than an hour. Thanks indeed!!

+8  A: 

Try character 10. It won't work in Firefox though. :(

The text is displayed (if at all) in a browser dependent manner. Small tooltips work on most browsers. Long tooltips and line breaking work in IE and Safari (use or for a new newline). Firefox and Opera do not support newlines. Firefox does not support long tooltips.

http://modp.com/wiki/htmltitletooltips

Stefan Mai
+1. If you decide to use a jQuery plugin, for optimal accessibility it should read its content from the title attribute and substitute some arbitrary invisible character for a line-break at runtime.
Kent Fredric
+1. Interesting stuff. There's still the issue of some UAs trimming the title when it pops up - FF2 as I recall but that's less of an issue these days.
sanchothefat
"(use or for a new newline)" i think you've got some markup problem there.
porneL
The link is DEAD
Josh Stodola
+2  A: 

&#13 will work in i.e. only

Greg Dean
+2  A: 

I don't believe it is. Firefox 2 trims long link titles anyway and they should really only be used to convey a small amount of help text. If you need more explanation text I would suggest that it belongs in a paragraph associated with the link. You could then add the tooltip javascript code to hide those paragraphs and show them as tooltips on hover. That's your best bet for getting it to work cross-browser IMO.

sanchothefat
+5  A: 

It's so simple you'll kick yourself... just press enter!

<a title='Tool
Tip
On
New
Line'>link with tip</a>

Firefox won't display multi-line tooltips at all though - it will replace the newlines with nothing.

Greg
LOl that's my favourite answer so far... I hope it works
ip
+2  A: 

The latest specification allows line feed character, so a simple line break inside the attribute or entity &#10; (note that characters # and ; are required) are OK.

This won't work in all current browsers, so make sure your text makes sense with newlines removed.

porneL
Actually, the specification requires the use of U+000A, that is:
Søren Løvborg
@Søren Thanks for correction.
porneL
A: 

& #xD ; <----- This is the text needed to insert Carry Return. (without spaces)

Regards

Juan