Adding alt text in CSS

Discussion in 'CSS' started by exodus123, Apr 24, 2010.

  1. #1
    Hello All,

    Please help me with my enquiry.

    I have this code in my CSS:

    #DesignImage1 {position:absolute;top:25px;left:190px;height:106px;background-image:url(../media/splashimage_new.jpg);background-position:top left;background-repeat:no-repeat;}

    This image is displayed at the header of my website. Can you please tell me how can I add alt text for this image? How should I add it in CSS?

    Thanks,
     
    Last edited: Apr 24, 2010
    exodus123, Apr 24, 2010 IP
  2. JustCause

    JustCause Guest

    Messages:
    192
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Alt text isnt added in CSS add it to your image tag so <img src="URL.jpg" alt="DESCRIPTION" />
     
    JustCause, Apr 24, 2010 IP
  3. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #3
    Alt is a attribute to be used for <img> tag and can't be feed through CSS. Background image is meant just to be used as a background. So that something on top can be placed on a background image.

    If you really want to have an ALT text for your logo which is appearing as an background, you can place a blank gif using <img> tag of your logo size and keep it over the background image and add an "Alt" attribute.
    for e.g. <img src="images/blank.gif" alt="Company Name" />
    Also, you can add "Titile" to your <a> tag.
    for e.g. <a href="index.html" title="Go to Home Page"> however Google does not index title attributes.
     
    radiant_luv, Apr 26, 2010 IP
  4. Shiloh88

    Shiloh88 Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I usually just do it in the <img> tag, too
     
    Shiloh88, May 3, 2010 IP