When building responsive websites I sometimes use background images to render an appropriate image for the appropriate screen size.
eg:
#image {
background-image: url(largeimage.jpg);
}
@media only screen and (max-width: 320px) {
#image {
background-image: url(smallimage.jpg);
}
}
To let screen readers know what kind of element we are dealing with I add
role="img"
And an
aria-label
Here is my question:
I've always learned that it's better for SEO to add an image like a company logo in an actual image element.
eg
<img src="logo-companyname.png">
The reasoning is that the logo will show up when Google image searching on the company name. (presuming the website is ranked well enough)
Will Google still "scrape" the logo when implemented as a div? eg
<div id="logo-company" role="img" aria-label="company name"></div>
Or do I still need to add an image somewhere to get the desired result? Does Google do anything at all with the screen reader tags for that matter?
Use an img tag. It's better for a number of reasons.
When to use <img />
alt
and title
attribute.When to use CSS background-image
Based on the list above and some observations we have these reasons to use an img
tag:
So: It's most likely best to use an img
tag
Google's John Mueller said in a webmaster hangout at the 20:55 mark that Google Image search does not index and rank images from CSS background code. He said if you want your images to rank in Google Image search then you best use normal image tag with the source attribute pointing at the image.
Here is a source:
Youtube
Article
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With