2

I have images in a gallery. To make it easier for me to crop the images to fit the boxes I want to use background instead of an image.

What does Google think of that? Hide an image with visibility: hidden (to get the scale right) and then add a background image to a before element?

It's not ment to trick users, but Google might see hidden content?

4

Google (and other bots) will see your html as it is. If you've got it as an image, they'll see it like that. If you Javascript it to the background, they won't notice, so it'll have no effect.

Although, Google (and maybe other bots) are starting to understand javascript. I recommend not hiding the image, simple remove it or load it as background in the first place.

My suggestion in this case would be to just insert it as background from the start. If your html is neat, that bit of alt isnt gonna give you that much juice ;)


Based on your comment and topic, if you make them a fixed size you could save yourself a whole lot work:

.item{
    width: 100px;
    height:100px;
    background: url('image.jpg');
    background-size:cover;
}

Background-size to cover alway shows as much image as possible, with the least amount of overflow horizontal or vertical. And is response.

  • 1
    Thanks for your answer. I have the img-tag there becuase it takes up space. That space is calculated by the height of the largest image in a row. I have hard to see another simple solution to the problem. Maybe I can add inline style and generate the height and width to the div with PHP instead. Not very beautiful HTML that way. – Jens Törnell Apr 17 '15 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.