Where does the alt text tag go?

Discussion in 'CSS' started by fuzzbuzz, Apr 30, 2008.

  1. #1
    Hi, I have a header image/logo which i want to add an alt tag to. Does it go within the css file or the html?

    css:
    #container {
    background: url(logo.png) no-repeat;

    html:
    <body>
    <div id="container">
    <div id="logo">

    Thanks

    fuzz
     
    fuzzbuzz, Apr 30, 2008 IP
  2. mike.greenleaf

    mike.greenleaf Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    First, ALT is an attribute, not a tag. It's used inside of the img tag (<img src="url" alt="description" ... />)

    Second, ALT is intended to be used for those users who cannot see your image in the first place. They are usually read by a screen reader program.

    When you insert a background image via CSS, as you have done, you cannot place an ALT attribute for the image (as far as I know). ALT exists on the content (X/HTML) side, while your image exists on the style (CSS) side. Those users who would rely on the ALT tag to know what you are trying to present graphically on your site more than likely would disable CSS on their browsers anyway.
     
    mike.greenleaf, Apr 30, 2008 IP
  3. ourblink

    ourblink Peon

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    alt is only in HTML
     
    ourblink, Apr 30, 2008 IP
  4. fuzzbuzz

    fuzzbuzz Active Member

    Messages:
    315
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    mike thanks for the explanation

    That makes sense now.
     
    fuzzbuzz, May 1, 2008 IP