1

I need to provide alt text for all my images, but I was not thinking about that when I put all my background images in the CSS under the body tag. The following is my my background image in my CSS that I need to add alt text to:


body
{
    background: url('contact.jpg') no-repeat center center fixed;
    box-shadow: inset 0 0 0 1000px rgba(0,0,0,.5), 0 0 0 1000px rgba(0,0,0,.5);
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

For other images that I put in the CSS I have been using:

<span class="background-image" role="img" aria-label="Cook in the rue de Stamboul, Constantinople, Turkey"> </span>

However, because I am using the body tag for the other background images there is no class. Therefore, I do not know how to provide the alt text for those background images. I would really appreciate y'alls help.

  • I think its answered here: [CSS background image alt attribute](https://stackoverflow.com/questions/4216035/css-background-image-alt-attribute). – Shuo Apr 17 '23 at 01:24
  • If it needs an alt, it probably shouldn't be a background image. If it's an integral part of the content, it should be an `img` tag complete with `alt` attribute. If it's purely visually decorative then a background image should suffcie. – Jon P Apr 17 '23 at 03:57

1 Answers1

0

I've seen some responses on a question a bit similar to this and some people are saying that background images are used only for aesthetic purposes and don't need an alt text.

CSS background image alt attribute

Another guy suggested using the title attribute which allows the title to appear as a tool tip when the mouse is hovered over the object

Coder868
  • 3
  • 3