Results 1 to 2 of 2

Thread: adding alt in CSS

  1. #1
    Join Date
    Dec 2005
    Posts
    133
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Default adding alt in CSS

    I have an image as background image andit is in a class in my .css file. Now I need to put an alt on that picture.
    Can I do it in the css?

    example:
    .header{float:left;display:inline;width:937px;height:74px;text-align:right;background:transparent url('../images/header_bg.gif') no-repeat;}

    this image needs an alt

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Technically speaking, it doesn't need an alt. Only image and area (perhaps one or two other) tags require an alt. Why would you want one? And no, there is no way to add an alternate attribute (or any attribute) via css. Css is only for assigning style property/value pairs.

    If you mean that when you move your mouse over the .header element you want a tool tip sort of thing to come up at the mouse pointer, you can give the .header element a title attribute:

    HTML Code:
    <div class="header" title="You are Pointing at my Header">Whatever</div>
    If a background image is missing, it simply isn't seen. If you want an alternate text for when it is missing, you must use an image tag for it. This usually can be done, especially as this is a no-repeat background image, by positioning its image tag absolutely or relatively and behind whatever it was originally the background for.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •