views:

118

answers:

3

I've a list of empty divs and dynamically inserting a background image – so at first, their background-image: url(); property is completely empty. With some event, it's background-image url loads into the previously empty background-image: url(); tag. The url of the appearing background-image is temporarily stored in the "alt" tag of the div:

<div style='background-image: url();' alt='http://something...'&gt;&lt;/div&gt;.

I'm doing so to get round corners on several animated gifs without using transparent gifs (no smooth edges).

Question: does Google robots index those images? I could imagine they do because the url is already stored in the html code and not in some external css-file, however not as "img" tag but as "alt" or "something" tag!?

+1  A: 

Googlebot (like most spiders) does not attempt to run javascript, so the only things it will index are the things appearing in the original HTML downloaded from the server. Any subsequent manipulation by JQuery just won't happen.

Also - most spiders don't index CSS either so background-images will also be ignored for that reason.

Paolo
Thanks for you answer. If Bots run javascript or not is not the problem. But do you know, if Bots index image-urls which are not in "href" or "src" tags but in the "alt" or some tag of a div?Thanks :)
Tobi
+1  A: 

I think @Paolo's answer is correct in general, but some bots might look for any kind of image resource referenced in the page - it's not unthinkable, and certainly not unethical.

If you want to make sure no search engine indexes the images, you can set up your robots.txt file to block them.

If you want to make sure bots do index them, you could for example set up a page containing <img> tags with all the images, and put an innocuous link to that page onto your front page.

Pekka
True, the caveat was "most" :)
Paolo
@Paolo yeah. It's perfectly possible they don't index images like that at all. It's just that I have seen pages and sub-sites on my own sites pop up in Google I was 100% sure I have never referenced anywhere that I have grown the general feeling that the Google bot is very greedy :)
Pekka
I will try to set up a page containing all the <img> tags, as you suggested.Thank you very much :)
Tobi
A: 

Googlebots will certainly index IMG ALT attributes. Whether or not they subsequently detect the fact that alt texts contain URLs and go looking at them, I really don't know.

This seems to me an abuse of the alt attribute, frankly: DIVs shouldn't (don't) have ALT attributes, and even if they did, this is not what they are for.

graphicdivine