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?

1 Answer 1


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:

    width: 100px;
    background: url('image.jpg');

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. Commented Apr 17, 2015 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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