A question on "title" and "alt" attributes

Discussion in 'HTML & Website Design' started by tayiper, May 10, 2006.

  1. #1
    This time, I am curious in regard to "title" and "alt" attributes: is there any written or unwritten "rule" on which elements to use them ?? I mean like to use them only on links (or only on graphics, read on) etc., since for instance IIRC, most folks use only the "alt" one on the graphics.


    thanks, tayiper
     
    tayiper, May 10, 2006 IP
  2. Corey Bryant

    Corey Bryant Texan at Heart

    Messages:
    1,126
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well the alt attribute is actually a required attribute on the <img> tag. So you should use that attribute on those tags.

    As far as the title attribute, I have never really used it. I am sure the_pm has the technical reason :)
     
    Corey Bryant, May 10, 2006 IP
  3. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #3
    as posted above, alt is used with images, for example:
    when you place your cursor on the image a little pop up shows the word 'image'

    i have used title tags for text links, for example:
    when you place your cursor on the link, you'll get a little pop up that says 'this is what it is'

    hope that helped
     
    sawz, May 10, 2006 IP
  4. Xig

    Xig Peon

    Messages:
    75
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The HTML 3.2 specification mentions "alt" as a valid attribute for <img>, <applet> and <area> (in <map>). According to MSDN, IE also supports <object>, <input> and <input type=image>.

    Hope that answers your question.
     
    Xig, May 11, 2006 IP
  5. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #5
    This is not really 100% true the alt is simply ment as an alternative to and object such as an image for when it is not possiable to display the image. This is why it should always be used, this is for accessablity reasons so people know what it is whith out seeing the image just of the alternative text.

    It is only IE that uses it to display with the mouse over, if you check in other browsers the alt attribue wont displat on mouse over, that is what the title attribue is for.

    So the title tag is use to display a text with a mouse over where as the alt attribute is only meant as an alternative for when something carnt be displayed as intended. Like when images are turned of and such. ;)
     
    johneva, May 11, 2006 IP
  6. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #6
    well, i guess you can teach an old dog new tricks, i started using firefox several months ago and never really used an alt tag, just tried it and it won't work in firefox for images, so i tried the title tag and it works fine.

    i also placed title tags in text links and it works fine in firefox.

    thanks for correcting me.
     
    sawz, May 11, 2006 IP
  7. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #7
    My pleasure matey. :)

    Thats the joys of using forums like this, there is such a weath of infomation between all the users that you are always learning so much and if you ever need help with something, there is a good chance that somebody has the answer.
     
    johneva, May 11, 2006 IP
  8. johniman7

    johniman7 Peon

    Messages:
    245
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Are you sure alt tags don't work in firefox? They popup little boxes for me.
     
    johniman7, May 11, 2006 IP
  9. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #9
    The alt attribute does not create a tooltip on mouseover. That IE does is contrary to the specs. Firefox follows the rules.

    Since the alt attribute should not cause a tooltip, and because it is annoying, you can stop IE from popping one up by using the title attribute with null content, eg. <img src="some.png" alt="blue flower in field" title="" />.

    cheers,

    gary
     
    kk5st, May 11, 2006 IP
  10. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #10
    Hehe, and what then IE displays in case of an "img" element with both attributes, i.e. with "title" and with "alt" one; maybe two separate tooltips ??


    Yeah, I assumed it is something like that. However, I already know that the "alt" one is used for the accessibility reasons (an alternative text, for instance for screen-readers, for people with disabilities etc.), but I was curious about various other elements. For example for the"title" attribute in partuicular, I've even seen it used inside the head tags; particularly in the "link" element referring to the extenral stylesheet-file.


    So like in this example:

    <link rel="Stylesheet" href="style.css" type="text/css" title="default">
    Code (markup):

    tayiper
     
    tayiper, May 12, 2006 IP
  11. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #11
    That is so you have assigned it a name.

    If you have the web developer toolbar for firefox click on CSS, go to disable styles, then go disable styles and it will list the styles sheets by the name you have assigned in the title tag.

    If you dont use the title attribute it will just give the URL of the stylesheet instead.

    That is one place where it is use I am sure there will be a few.
     
    johneva, May 12, 2006 IP
  12. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #12
    No, the title attribute's presence will suppress the alt tooltip. See my post just prior to yours.

    cheers,

    gary
     
    kk5st, May 12, 2006 IP
  13. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #13
    Ah sorry yeah I missed that part of your question, but what kk5st says. ;)
     
    johneva, May 12, 2006 IP
  14. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #14
    Yeah, this is a so-called IE's "non standard" behaviour, totally uhm ...


    tayiper
     
    tayiper, May 12, 2006 IP
  15. ylikone

    ylikone Active Member

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #15
    I always put both alt and title parameters in my img tags... that way all browsers get the mouseover text coming up.
     
    ylikone, May 15, 2006 IP
  16. johneva

    johneva Well-Known Member

    Messages:
    1,480
    Likes Received:
    46
    Best Answers:
    1
    Trophy Points:
    170
    #16
    Just by putting title it will do that too.

    But what it wont do if you only use the title attribute is show alternative text if the image or object carnt be showen for some reason, that is why you should always use the alt attribute for accessiablity reasons.

    Then the title tag is for your mouse-over effect if you want it.
     
    johneva, May 16, 2006 IP
  17. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Well since you asked ( ;) ), I'll mostly echo what others have said and I'll try to insert an original thought or two as well.

    Alternative text is just as it sounds - it is text that serves as a suitable replacement for an object if that object were to fail to load. There are times when you don't want to use alternative text as an attribute, because the context of the missing object is explained through other devices. For example, if you had an image of you and your dog, and the very next item on the page was a heading tag that said "This is Paul and his dog fluffy," you would want the alt attribute to be blank within the image tag, because otherwise you'd have redundancy from a functional perspective (someone "viewing" the page with a screen reader would not be impressed, nor would someone browsing with images turned off).

    Title text supplements an object. It cannot be required reading; you don't want to create objects that don't make sense unless the title text appears, because interacting with those objects is an optional end-user activity. So titles do not replace objects - they embellish them. Frankly, I've never been terribly impressed with titles, since the end user cannot control how long they remain, and there is no style recourse (which is paramount to accessibility), at least none that I've ever seen - there might be within working draft specs.
     
    the_pm, May 16, 2006 IP