Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alt tag max length??

Status
Not open for further replies.

bamboo

Programmer
Aug 22, 2001
89
US
Does anyone know if there is a max char length for the alt tag before it stops working within Netscape? I did a search within these forums and found one thread, but the person only tested it in IE. All my alt tags seems to work fine in IE, but in Netscape the longer ones don't display.
 
alt attribute exists in <img> tag and will display when image was not properly loaded. Or when user uses a browser without images. As such it is best to keep your alt attributes short and descriptive, somewhere between 8 and 70 characters. IE also incorrectly shows the value of alt when hovered over with mouse in a form of tooltip. The attribute for this tooltip is title however. With the following code:
Code:
<div style="width: 300px; height: 300px; background: blue; color: white;" title="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut tempor metus non augue. Etiam porttitor mi ut quam. Vestibulum eleifend, est sit amet adipiscing elementum, sem nulla rutrum justo, vitae fringilla nulla felis ut nulla. Duis interdum. Vestibulum tristique pharetra sapien. Vivamus ligula. Sed ut ipsum at quam malesuada laoreet. Ut semper magna et lacus. Mauris at urna. Nulla suscipit dolor in tellus blandit tristique. Proin cursus enim in urna. Vivamus felis lacus, ornare vitae, bibendum a, rhoncus non, erat."></div>
IE and Opera show the whole tooltip while Mozilla cuts the text at 'metus non augue. E...'. All three browsers display the tooltip.
 
IE also incorrectly shows the value of alt when hovered over with mouse.

I disagree that IE shows the alt tag "incorrectly". It correctly shows the ALT text if no image is present (or while the image is loading), and if both ALT and TITLE are present, it will always show the TITLE text on a mouse over, and the ALT text as the placeholder text. But to say that showing the ALT text on a mouseover is incorrect (when no TITLE text exists)... Well, is that really true? I don't know of any references that say browsers / user agents should NOT show initiative by showing the ALT text when hovering the mouse over an image...

Just my 2 pence worth ;o)

Dan
 
I suppose it depends on what you mean by "incorrect". The spec does not say that [tt]alt[/tt] text should be displayed in a tooltip, but it doesn't say that it shouldn't either. But can we really expect the spec to enumerate all the things that browsers shouldn't do?

Suppose a browser decided to display [tt]alt[/tt] text below the image as a caption? I think we'd all agree that that was wrong, but it's not explicitly prohibited in the spec. How about reading it out loud on your speakers at 200MB when you mouseover? Nothing about that either.

Reductio-ad-absurdum aside, we have to be guided by what the spec says [tt]alt[/tt] text is for: "For user agents that cannot display images, forms, or applets, this attribute specifies alternate text". The key word (for me) is "alternate" - if you can't get images, you get this text as an alternative. That implies to me that if you can get images, you shouldn't see the [tt]alt[/tt] text. Not even in a tooltip.

If I want a tooltip, I'd rather ask for one, using the [tt]title[/tt] attribute. As it is, I have to add [tt]title=""[/tt] attributes to images when I don't want them, purely to suppress IE's (mis)behaviour.

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top