Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to show alt="text" as a mouseover tooltip in firefox like IE does automatically?

I don't want to repeat alt text in title again? is this possible with any javascript , jquery, css solution? or any solution which can disable to show alt=text and enable title=texr and as a tooltip?

like image 366
Jitendra Vyas Avatar asked Nov 14 '09 16:11

Jitendra Vyas


People also ask

Does alt text show up on hover?

The text that appears when you hover on an image with your mouse is the “title tag” (or tool tip). The alt text for an image, however, is shown when the image cannot be displayed. For example, visually impaired users will have the alt text read to them to describe the image.

How do you add a hover message?

There are two ways you can create a hover text for your HTML elements: Adding the global title attribute for your HTML tags. Creating a tooltip CSS effect using :before selector.

How do you reveal alt text?

Chrome™ browser: point to the image with your mouse, right-click and choose Inspect from the quick menu (or use Ctrl-Shift-I on keyboard). A new pane will open at the right of your screen with the HTML code highlighted for that element. You can then view the alt text and other attributes for the image.

How do I show hover messages in HTML?

HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext" .


2 Answers

The correct way to do this is to use the title attribute.

e.g.

<div title="This is your tooltip">...content...</div>

The "alt" attribute is only designed to provide "alternative" text when an image element is used (but not available to the user... e.g. blind users, or users with text-based browsers etc.)

like image 69
scunliffe Avatar answered Oct 06 '22 06:10

scunliffe


alt text is for an alternative representation of an image. title text is for tooltips.

IE's behavior is incorrect in this regard, and Firefox will never implement it. (The bug in the Bugzilla database is #25537, which is VERIFIED WONTFIX.)

Not only that, but even Microsoft has admitted that their behavior is incorrect, and IE 8 doesn't show alt text as tooltips anymore!.

So don't rely on alt text being displayed as a tooltip. Use title instead.

like image 45
Daniel Pryden Avatar answered Oct 06 '22 05:10

Daniel Pryden