Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to format an HTML tooltip (title attribute)? [duplicate]

Tags:

html

tooltip

Is it possible to format an HTML tooltip?

E.g. I have a DIV with attribute title="foo!". When I have text-size of my browser zoomed in or out in, the text size of the tooltip remains unchanged. Is there a way to make the tooltip font scale with the browser setting?

like image 208
sunflowerpower Avatar asked Jan 27 '09 16:01

sunflowerpower


People also ask

What is tooltip attribute in HTML?

HTML title Attribute The title attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.

Can you style a tooltip?

You cannot style the default browser tooltip. But you can use javascript to create your own custom HTML tooltips.

How do you style a tooltip title?

The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" . CSS: The tooltip class use position:relative , which is needed to position the tooltip text ( position:absolute ). Note: See examples below on how to position the tooltip. The tooltiptext class holds the actual tooltip text.


2 Answers

Try using entity codes such as &#013; for CR, &#010; for LF, and &#009; for TAB.

For example:

<div title="1)&#009;A&#013;&#010;2)&#009;B">Hover Me</div>
like image 130
Louis Avatar answered Sep 22 '22 19:09

Louis


No. But there are other options out there like Overlib, and jQuery that allow you this freedom.

  • jTip : http://www.codylindley.com/blogstuff/js/jtip/
  • jQuery Tooltip : https://jqueryui.com/tooltip/

Personally, I would suggest jQuery as the route to take. It's typically very unobtrusive, and requires no additional setup in the markup of your site (with the exception of adding the jquery script tag in your <head>).

like image 28
Sampson Avatar answered Sep 20 '22 19:09

Sampson