SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Title atribute on <a> element

    When I use the element <a> for linking to another URL I can include the title attribute to describe the site to which I am linking to. My question is whether this "title" attribute is mandatory when I write html 4.01 strict.
    Julio

  2. #2
    SitePoint Zealot seoindiauk's Avatar
    Join Date
    Aug 2009
    Location
    New Delhi, India
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Quote Originally Posted by julioa View Post
    When I use the element <a> for linking to another URL I can include the title attribute to describe the site to which I am linking to. My question is whether this "title" attribute is mandatory when I write html 4.01 strict.
    Julio
    No its not. But when a visitor put his cursor over that link, title tell about that link.
    Last edited by seoindiauk; Sep 7, 2009 at 08:00. Reason: error

  3. #3
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great seoindiauk

  4. #4
    SitePoint Zealot seoindiauk's Avatar
    Join Date
    Aug 2009
    Location
    New Delhi, India
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Quote Originally Posted by julioa View Post
    Great seoindiauk
    Its ok, are you satisfied?

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    The title attribute is supposed to be optional on any tag in the body of your page. The only tag where omitting it makes a difference is the <img> tag where if it is left off will result in IE incorrectly setting the title attribute equal to the alt attribute.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    I would say the title attribute should be required for anchor links, it gives people an idea of what they will find behind each hyperlink if they choose to click (beyond the basic information given in the link text), it has some obvious benefits for accessibility.

  7. #7
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AlexDawson View Post
    I would say the title attribute should be required for anchor links, it gives people an idea of what they will find behind each hyperlink if they choose to click (beyond the basic information given in the link text), it has some obvious benefits for accessibility.
    Sometimes the link text is all you need to describe a link's destination.

  8. #8
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    While that is a valid point I still believe giving a bit more detail can only be a good thing, you could give it a bit of humor or greater detail of the contents!

  9. #9
    SitePoint Enthusiast
    Join Date
    Nov 2008
    Location
    Minnesota
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To not use it is a missed opportunity to improve your SEO, besides just being informative for the visitor.

    Chris

  10. #10
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AlexDawson View Post
    I would say the title attribute should be required for anchor links, it gives people an idea of what they will find behind each hyperlink if they choose to click (beyond the basic information given in the link text), it has some obvious benefits for accessibility.
    Most sites that I have seen that do use a title attribute on all their links simply repeat the text that is already in the link itself and so are not making the link any more accessible than it is without the title.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  11. #11
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    According to http://www.w3.org/TR/html4/strict.dtd no.
    Title is IMPLIED, not REQUIRED.

    Code:
    <!ENTITY &#37; coreattrs
     "id          ID             #IMPLIED  -- document-wide unique id --
      class       CDATA          #IMPLIED  -- space-separated list of classes --
      style       %StyleSheet;   #IMPLIED  -- associated style info --
      title       %Text;         #IMPLIED  -- advisory title --"
      >
    I only use a title attribute on links when there is an <img> instead of text used as the thing that's clicked. I figure when it's text there's no reason to add redundant text. The context of the link should be giving the reader a good enough idea of what the link goes to. With an image, there should still be enough context to get a general idea, but given the attributes on the <img> are designed to describe the <img> itself, the title serves a non-redundant purpose on the link.

  12. #12
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by joebert View Post
    With an image, there should still be enough context to get a general idea, but given the attributes on the <img> are designed to describe the <img> itself, the title serves a non-redundant purpose on the link.
    Since you must have a title attribute on an image anyway so as to correct for an IE bug, why not just put your text there instead of adding a second title to the link.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  13. #13
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Since you must have a title attribute on an image anyway so as to correct for an IE bug, why not just put your text there instead of adding a second title to the link.
    Second title ?
    IE Bug ?

    // Edit - ah I see what you mean.

    IE doesn't like to display the ALT text of an image when you hover over it, but it will display a TITLE.

    An image element requires an alt, but not a title.
    To use a title on the image to describe the resource the parent link node points to and an alt with different text to describe the image itself, creates a double standard for what that title attribute is for.

    It makes more sense to use the title with the link element.

    IE will pickup the links title just fine, you'll get the hover effect.
    Screen readers will have something to describe the destination of the link with immediately, followed by a description of what the image looks like if they're interested.

  14. #14
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I try to put title attributes on links when the destination is not plainly obvious from context. I started this after (for a time) I ran Firefox fullscreen while browsing. Losing the contextual URL‐on‐hover made me feel quite blind, particularly when browsing wikis like TVTropes.

    Although not mandatory, I think it’s something many visitors would appreciate.

  15. #15
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by joebert View Post
    IE doesn't like to display the ALT text of an image when you hover over it, but it will display a TITLE.
    No it is actually the reverse. If you don't put a title on an image IE will incorrectly copy the alt text into the tile and display that. Only by specifying a title on all your images can you prevent IE 's misuse of the alt attribute (which is only supposed to display in place of the image if the image can't be seen).

    If you don't have an empty title on the image and you wrap the image in a link with a title then you have two titles for IE to display when you hover over the linked image (the one from the link and the one the IE bug generates from the alt attribute of the image).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  16. #16
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Regarding the title attribute improving accessibility, the last time I checked, major screen readers (including JAWS) simply included a user preference that allowed the user to choose whether to hear the link text or the title attribute when it encountered links with a non-empty title attribute value set.

    What this means is, not only can you not assume that screen reader users will hear your title attribute text, but you must allow for the possibility that they will only hear your title attribute text, and not the link text!
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  17. #17
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    No it is actually the reverse. If you don't put a title on an image IE will incorrectly copy the alt text into the tile and display that.
    Not in the browser I'm looking at right now.

    Code:
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)

  18. #18
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kevin Yank View Post
    Regarding the title attribute improving accessibility, the last time I checked, major screen readers (including JAWS) simply included a user preference that allowed the user to choose whether to hear the link text or the title attribute when it encountered links with a non-empty title attribute value set.

    What this means is, not only can you not assume that screen reader users will hear your title attribute text, but you must allow for the possibility that they will only hear your title attribute text, and not the link text!
    Option between title attribute or link text.
    What if it doesn't find any link text ?
    Isn't the alt attribute what the reader is going to naturally return to the visitor since obviously for them the image isn't visible ?

  19. #19
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by joebert View Post
    Option between title attribute or link text.
    What if it doesn't find any link text ?
    Isn't the alt attribute what the reader is going to naturally return to the visitor since obviously for them the image isn't visible ?
    Who said anything about images?

    If the only thing inside a link is an image, then yes, the alt attribute of that image is the link text.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  20. #20
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,597
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by joebert View Post
    Not in the browser I'm looking at right now.

    Code:
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
    Perhaps they fixed it in IE8 - it was definitely a bug in IE6.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  21. #21
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, it was fixed in IE8, but only in IE8 mode (the compat view and quirks modes still show alt in a tooltip).
    Simon Pieters

  22. #22
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,233
    Mentioned
    47 Post(s)
    Tagged
    1 Thread(s)
    Option between title attribute or link text.
    What if it doesn't find any link text ?
    Isn't the alt attribute what the reader is going to naturally return to the visitor since obviously for them the image isn't visible ?
    JAWS10, default settings:

    If an image has both title text and alt text, only alt text is read out. If alt="" then title text is read out. I haven't bothered looking for the settings for both.

    If an anchor has no actual text but has title text, the title text is read out as if it were regular anchor text. I don't hear a difference.

    If an anchor has both actual text and title text, title is skipped. I don't hear that there even is a title. Which is good, what's more annoying than going through a menu the third to hundreth time and hearing

    back to the home page home
    learn more about the company about
    learn more about our products products
    you can contact us here contact

    or worse, as Felgall stated, most people do this (I think many of them do it because it's a default in their wysiwyg):
    home home
    about about
    products products
    contact contact

    Bleh. I refuse to add titles unless they add meaning, and even then, I'd rather not at all on a site menu. It's useful for in-page links that are one-offs and maybe need some explaining, but then you can't rely on them as keyboarders without a screen reader don't get any of that title text (that I know of?).

  23. #23
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by seoindiauk View Post
    Its ok, are you satisfied?
    yes thxs

  24. #24
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by julioa View Post
    yes thxs
    An all the board thanks too.

  25. #25
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by felgall View Post
    Most sites that I have seen that do use a title attribute on all their links simply repeat the text that is already in the link itself and so are not making the link any more accessible than it is without the title.
    Of course but it makes sense not to repeat the contents of an anchors text within the title. I provide titles on the basis that the anchor text is simply the reference point which indicates to the reader there is more information available, where as the title provides contextual meaning explaing what they will find... for example you could have an anchor link which links to the "About Us" section of a website but have a title with the value of "Find company and staff details."

    Quote Originally Posted by Kevin Yank View Post
    What this means is, not only can you not assume that screen reader users will hear your title attribute text, but you must allow for the possibility that they will only hear your title attribute text, and not the link text!
    Which is why I would prefer to have both, it also stands to reason that on occasion the anchor text may not be indictive of the contents of the site (for example what if the anchor text is a URL - very common on the web), this isn't exactly screen reader friendly but a title could help clear up the confusion by giving contextual information rather than just reading the visual representation of the URL on display.


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
  •