4
votes

While we ask a question, SO shows related questions. If we hover on the questions the content is displayed as a tooltip which contains linebreaks, indentations etc. What technique SO uses for it? How to display tooltips wit the formatting?

Other than, jquery/javascript is there any simple way to achieve it?

Was just wondering, should i ask this on Meta?

2
I know simple linebreaks work on a few browsers. Also, 
 on some. But I want it to work on all the browsers. - San
I know the use of title attribute too! I just want linebreaks on it. - San
SO's tooltip works fine on IE6 too! - San

2 Answers

6
votes

It is just a title attribute on the hyperlink, plain and simple.

<a href="..." title="The value is approximately
        3.14159265
    but for simplicity you can always round it
    to exactly 3.0">What is the value of Pi?</a>

In IE, Chrome & Safari, it honors the line breaks a bit more strictly than say Firefox or Opera.

1
votes

I took this html actually from stackoverflow. Here is no magic here:

Here's a dumb question which I can't find an answer to:
I have a table which contains 20 fields, a few of which are date/time. I am interested in pulling all the fields. I would like to  … ">Selecting fields in SQL Select statements (Dumbest SQL Question)</a>

As you see, title can have line breaks!