Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an alt attribute be set using CSS?

Tags:

html

css

alt

I'm setting an image using a <div> tag like this:

<div id="logo"></div>

and here's the CSS:

    #logo {
      background: url(../images/logo.png) no-repeat center;
      width: 180px;
      height: 82px;
      float: right; 
      padding: 15px 15px 0 10px;
      position: relative;
    }

How do I set an alt="" attribute for the image?

thanks!

like image 866
hanumanDev Avatar asked Oct 25 '25 04:10

hanumanDev


1 Answers

It is impossible to set an <img alt=""> with css. But this can be done with JavaScript Example

<div class="logo><img src="../image.png"></div>

document.getElementByTagName('img').alt = "Anything";
like image 104
Oke Tega Avatar answered Oct 26 '25 18:10

Oke Tega



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!