alt and title in <img> tag?

S

Suzanne Knapp

Is it ok to use both alt and title attributes in an <img> tag (so all
browsers will honor at least one of them)?
 
D

Dylan Parry

Using a pointed stick and pebbles, Suzanne Knapp scraped:
Is it ok to use both alt and title attributes in an <img> tag (so all
browsers will honor at least one of them)?

Yes, it is fine. In fact you *should* be using alt attributes for all
your images. With regards support, I don't know of any browsers that
*don't* support the alt attribute, but I think that Netscape 4 didn't
support title attributes.

Internet Explorer will use the alt attribute as a tooltip, which is
wrong, but will use the title attribute in preference if it is present.
 
D

Dan

Suzanne said:
Is it ok to use both alt and title attributes in an <img> tag (so all
browsers will honor at least one of them)?

You should use them in accordance with their standards-compliant
purpose; the ALT attribute is required for all images and should
consist of whatever the image ought to be replaced with if not
displayed (e.g., in a text browser), which may sometimes be a null
string (for spacers and purely decorative images). The TITLE attribute
is not required, but can be used for supplemental information where
this is relevant.
 
V

Vladdy

Dan said:
You should use them in accordance with their standards-compliant
purpose; the ALT attribute is required for all images and should
consist of whatever the image ought to be replaced with if not
displayed (e.g., in a text browser), which may sometimes be a null
string (for spacers and purely decorative images).
Spacers have reason to be in HTML in this day and age.
Purely decorative images belong in CSS as element backgrounds.
 
S

Suzanne Knapp

Thanks. I didn't realize that IE's display of Alt text was erroneous - I
thought that was what was supposed to happen, and was surprised when FireFox
didn't do it. At the FF site I learned that they would display Title text,
so thought that using both attributes (with the same text) would give me
what I wanted. So far so good with IE 6 and FF, haven't tried any others
yet.
 
D

dorayme

From: Dylan Parry said:
Using a pointed stick and pebbles, Suzanne Knapp scraped:

Yes, it is fine. In fact you *should* be using alt attributes for all
your images. With regards support, I don't know of any browsers that
*don't* support the alt attribute, but I think that Netscape 4 didn't
support title attributes.

Internet Explorer will use the alt attribute as a tooltip, which is
wrong, but will use the title attribute in preference if it is present.

I'd say to be careful about titles, they seem to invariably produce pop out
bubbles which are sometimes a distracting nuisance...

(1) Once I was greatly irritated because I was using the mouse to point
things out to someone in a picture, every time the mouse moved the bubble
would pop up. (2) I have had cases of these pop outs obscuring things I
wanted to see. (3) I *wanted* to read the content of the bubbles but they
refused to stay long enough! (Sorry, it sounds like I am hard to please...
but there is a serious point here.)

Surely all browsers "honor" alt tags? So the decision is when to use
"title". I'd say, only if you want the viewer to briefly see some very short
extra info ... in an image not likely to be so great that a viewer might
want to lovingly feel all over it with a mouse...

dorayme
 
S

Suzanne Knapp

The popouts are the effect I was trying for, so Title is fine for that
purpose. They stay on as long as the cursor is over the image, which is
what I want. The only problem is older browsers that don't display title
text, and the Alt text covers those (at least the ones I know about).

Suzanne
 
M

Mark Parnell

Previously in alt.html said:
I'd say to be careful about titles, they seem to invariably produce pop out
bubbles which are sometimes a distracting nuisance...

On IE, alt does the same.
Surely all browsers "honor" alt tags?

*Attributes*. alt *attributes*. :)
So the decision is when to use
"title".

Use an empty title (title="") to stop IE from displaying the alt
attribute as a tooltip.
 
M

Mark Parnell

Previously in alt.html said:
Thanks. I didn't realize that IE's display of Alt text was erroneous - I
thought that was what was supposed to happen,

A common misconception, thanks to IE's behaviour. :-(

According to the specs -
http://www.w3.org/TR/html4/struct/objects.html#adef-alt - the alt
attribute specifies a textual *alternative* to the image. IOW, it is
supposed to be displayed only if the image *isn't*, for whatever reason.
 
D

dorayme

From: "Suzanne Knapp said:
Newsgroups: alt.html
Date: Mon, 04 Jul 2005 23:58:54 GMT
Subject: Re: alt and title in <img> tag?

The popouts are the effect I was trying for, so Title is fine for that
purpose. They stay on as long as the cursor is over the image, which is
what I want. The only problem is older browsers that don't display title
text, and the Alt text covers those (at least the ones I know about).

Suzanne


Yes, I gathered that you probably did want this popout. In my experience
there is a time limit for their existence even if the mouse is not moved but
I won't bother you on this as it might be a quirk of my mac browsers (I am
now wondering if there is any setting for this?). Still, I do think it is
probably a good idea to keep the title nice and short for reasons you can
gather from my last post...

dorayme
 
M

Mark Parnell

Previously in alt.html said:
In my experience
there is a time limit for their existence even if the mouse is not moved

In Mozilla/Netscape/Firefox it is about 6 secs IIRC.
(I am
now wondering if there is any setting for this?).

Not in any browser that I know of.
Still, I do think it is
probably a good idea to keep the title nice and short for reasons you can
gather from my last post...

Plus the Mozilla family of browsers doesn't always display the whole
title attribute anyway - it cuts it off if it is too long. It depends on
exactly what it is, but it tends to be around 100 characters.
 
D

dorayme

From: Mark Parnell said:
On IE, alt does the same.
Yes, I know but one *has* to put in alt attributes if one wants to be kosher
....
*Attributes*. alt *attributes*. :)
Yes, and oops! But thanks, loose talk...
Use an empty title (title="") to stop IE from displaying the alt
attribute as a tooltip.
Ah so! An interesting point, especially for me who is keen to be sparing
about tooltips.

dorayme
 
D

dorayme

Just a further note, on one IE (for Mac version 5.1.6), the alt attribute
does not trigger tool tips, the title does though when added. There are many
features to IE 5 for Macs that seem much more solid than the PC version. I
understand that the people who developed the Mac version had a bigger clue
about what they were doing (one source for this was a remark by SP a while
back, but also others and my own observations)
 
B

Blinky the Shark

dorayme said:
I'd say to be careful about titles, they seem to invariably produce
pop out bubbles which are sometimes a distracting nuisance...

The day I turned off "tooltips" (in which category Opera includes the
title attribute) for good was the day I was trying to read a long
article on a page with very long paragraphs where each *entire
paragraph* (i.e., nearly the whole page!) had a title. It kept popping
up boxes every time I brought the cursor onto the page to click a link.
And the titles were something useless like "Chapter 14".

I only have one title attribute at blinkynet, and it's been there for
years. Last week, I added a second, and scratched a small bald spot on
my head, trying to figure out why Opera (which is no longer my primary
browser) wouldn't show it. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top