SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2012
    Posts
    117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Implement title-attribute on linking image

    Hi there,

    I was wondering what is the best way to implement the title and alt on a linking image.

    An img-tag can have both the title and alt attributes, an a-tag can only have the title attribute.
    When linking an image what is the best way to implement the title-attribute?
    Should I put it on both the img and a-tag or just one of the two?

  2. #2
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,881
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Vincentas View Post
    I was wondering what is the best way to implement the title and alt on a linking image.

    An img-tag can have both the title and alt attributes, an a-tag can only have the title attribute.
    When linking an image what is the best way to implement the title-attribute?
    Should I put it on both the img and a-tag or just one of the two?
    Before you go ahead and put the title on anywhere, have a read of David Bell's article on screen readers (thanks to @Stomme poes for bringing it to our attention), where he describes why the title attribute does absolutely nothing for people using access technology. And in many cases it does nothing for people using a traditional desktop computer with no impairments either, because they simply won't hover the cursor round looking for tooltips. If the information title is both useful (ie, doesn't simply replicate what you've already got on the page) and non-essential (ie, it doesn't matter if half the people don't see it) then go with it, but if it fails either of those tests then you're better off not using it.

    Whether you put the title on the <a...> or the <img...> depends on what the purpose of it is. If it's describing the picture then it belongs in the <img...>, but if it's describing the link destination then it belongs on the <a...>.

  3. #3
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,271
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Steve Faulkner gives a good overview of when to use it: http://www.paciellogroup.com/blog/20...tle-attribute/

    It's best to have good link text within your anchors, and good alt text within your images. If an image is inside an anchor, the alt text often should be as good as what your link text would be, assuming alt text is taking its place.

    Images who are purely decorative, such as bullet icons, should be alt="", since otherwise many readers will read out the whole image URL which sucks and usually is useless to everyone.

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2012
    Posts
    117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for advices


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •