Forum Moderators: open

Message Too Old, No Replies

Alt vs. title

What's the difference?

         

Sinner_G

3:42 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which one to use for an image?

I've heard and read a lot, like a title attribute lasts longer or can include more text, but can't find any hard facts on w3c.

andreasfriedrich

4:13 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe there exists a general rule for choosing the appropriate rule when two or more may be applicable:

Use the most specific one.

The title attribute may be used on most elements. It offers advisory information about the element for which it is set.

The alt attribute must be specified for image elements. So using alt which you are required to do and having a title attribute is IMHO redundant.

Andreas

Sinner_G

4:19 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Doesn't make a lot of sense to me. Why then is there an alt at all? It would have been enough to have the title attribute possible for all elements and mandatory for img.

Furthermore, I remember reading somewhere that NS6 doesn't support alt.

tedster

4:24 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The alt attribute is an alternative to the image, for those visitors who don't display images for whatever reason.

The title attribute is "intended" for all users.

The main bit of browser craziness right now is what a browser shows in the tool-tip. The W3C recommendation is to show the title attribute, but Explorer shows the alt attribute, keeping the web off-standard.

andreasfriedrich

4:24 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Historic reasons? Backward compatibility?

If NS6 claims to support HTML4 or XHTML1 it better support the alt attribute:

[w3.org...]

Sinner_G

4:28 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me see if I get this right. I could have an image like this:

<img src="picture.gif" alt="I love Microsoft" title="I hate M$"> :)

and I would get cheers from everybody?

But still doesn't tell me if there are any differences in length/time.

sun818

4:55 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The other way around :)

<img src="picture.gif" alt="I hate M$" title="I love Microsoft">

tedster

5:03 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What do we mean when we say a browser "supports" the alt attribute? Turn off graphics. If the alt attribute is displayed in place of the image, then the browser supports it. There's no reason to display an "alternative" if the image itself is displayed.

Some of the comments here seem to be addressing the tool-tip, the little fly-out box that appears when you rest the cursor over an image. That "should" be the title attribute, when it's present.

The behavior of the tool-tip (how long it lasts, whether its text wraps, etc.) are up to the browser maker right now, as far as I know.

Many other uses for the title attribute exist. For instance, if an anchor tag has a title attribute, then Opera displays the title in the status bar instead of the "geeky" URL - that's much more user friendly, IMO.

I've been also been using title attributes for <blockquote>. It's there to help our site search function, mostly, because I don't think it gets used by any current SE. But it sure is helpful.

g1smd

7:24 pm on Oct 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The alt attribute is required in HTML 4.01 as it is used by non-visual browsers such as speaking browsers and Braille browsers for the blind.

It is also used in place of the image if it fails to load on a visual browser.

Older browsers use the alt text as the pop-up text when you hover the mouse over an image. Newer browsers use the title attribute for the pop-up text.

starway

6:53 am on Oct 28, 2002 (gmt 0)

10+ Year Member



Read my post on this topic here:
[webmasterworld.com...]