How can I build a responsive Mobile First page with images optimized for SEO with Alt and Title?
At the moment I change the image source in the CSS file like this:
section.value-offer > div.container > figure {
background: url('../Images/Shop/img.childrens.480x320.jpg') top center no-repeat;
background-size: cover;
padding-bottom: 66.66666666%;
height: 0;
}
And in the HTML I use only:
<figure></figure>
Then in the CSS responsive part for the next page size I do:
@media only screen and (min-width : 480px) {
background: url('../Images/Shop/img.childrens.768x511.jpg') top center no-repeat;
}
But I can’t do:
<figure alt="Image of Childrens" title="Image of Childrens"></figure>
And I can’t put the IMG tag with the SRC because I can’t change it using CSS only.
2
Answers
If you would like these images to ever rank in any modern search engine image search (and that is the purpose of your question I guess) then you should not use them as css background images as this would not get indexed by them. Going for semantic html (
<figure>
) is a right choice but depending on the image and content structure you can also use plain old<img>
tag. Here is a good starting point if you need to find out more about responsive images.Also I would recommend using fore mentioned scrset, despite IE’s lack of adoption of this attribute. There is a easy work around, IE will ignore
scrset
attribute but still use thesrc
so you can source your default IE image from there:If you have SEO / cross browser (including IE) constraints, I would suggest this
Have a mobile first approach with such HTML
It means that by default, client (mobile here) will fetch the smaller image dedicated to mobile
Then, for larger screen (desktop or even tablet), you will have such applied CSS
If your media queries are well defined, it means that yes: desktop will download the smaller image in all cases + a much larger one.
But at least, you limit the size of downloaded assets for mobile, also assuming that desktop are on a more solid connexion.