SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Title tag or just Src

    If I have a photo should title be used as an attribute with it or is the src attribute enough? This should be an easy answer to search out but I cannot get a definitive answer on any HTML site.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by OBEagle View Post
    If I have a photo should title be used as an attribute with it or is the src attribute enough? This should be an easy answer to search out but I cannot get a definitive answer on any HTML site.
    - Title doesn't show up in the display portion, so to make it a title, it should be the first element on the page. Being in the <body> tag. Let me know if I understood your inquiry.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This might be a better example. Which is best or correct?

    <img src="photo1" alt="A great photo example">

    or

    <img src="photo1" alt="A great photo example" title="A great photo example">

    Sorry, I typed src in the original post when I meant alt.

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The alt attribute should convey the same information, if any, as the image does in that particular context. It will be shown when the image cannot be shown.

    The title attribute can be used to show non-critical information in relation to the image. It should probably never be the same value as the alt (unless both are empty).
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    The alt attribute should convey the same information, if any, as the image does in that particular context. It will be shown when the image cannot be shown.

    The title attribute can be used to show non-critical information in relation to the image. It should probably never be the same value as the alt (unless both are empty).
    Thanks for clearing that up. Have a good day.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,868
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    One more thing is that there is a bug in Internet Explorer where if you don't specify a title then it creates one with the content of the alt attribute. So if you want consistent results across all browsers you should always specify a title even if you specify title="" in order to tell IE that there isn't one.
    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="^$">

  7. #7
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    One more thing is that there is a bug in Internet Explorer where if you don't specify a title then it creates one with the content of the alt attribute. So if you want consistent results across all browsers you should always specify a title even if you specify title="" in order to tell IE that there isn't one.
    You'll be happy to learn that this bug has been eliminated in Internet Explorer 8
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,868
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by C. Ankerstjerne View Post
    You'll be happy to learn that this bug has been eliminated in Internet Explorer 8
    So once everyone using IE is using version 8 or later it will not be necessary to always supply a title attribute but while there are still lots of IE6 and 7 users it is still necessary to use the title attribute to work around the bug in those browsers.
    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="^$">

  9. #9
    SitePoint Member
    Join Date
    Apr 2007
    Location
    Perth
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using title is always good for SEO
    Flamingcow Design - Perth, WA

  10. #10
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    So once everyone using IE is using version 8 or later it will not be necessary to always supply a title attribute but while there are still lots of IE6 and 7 users it is still necessary to use the title attribute to work around the bug in those browsers.
    To be honest I liked that bug in IE...sometimes reading the ALT was the only way to actually tell what action clicking on a certain image does. Referring to UI where the developer was to lazy to label thing except with images.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  11. #11
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,868
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by logic_earth View Post
    To be honest I liked that bug in IE
    You can get that exact behaviour in ALL browsers if that is what you want simply by setting the title 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="^$">

  12. #12
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    You can get that exact behaviour in ALL browsers if that is what you want simply by setting the title attribute.
    Right...but I don't control the source code to do that in the various UIs I've ran into with that problem.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  13. #13
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by scross View Post
    Using title is always good for SEO
    No it isn't. The title attribute isn't even indexed by search engines.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  14. #14
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help and the discourse taking place. All the post here regard questions and concerns I had after doing a search on the title attribute.


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
  •