Here is my code:
<a itemprop='image' target='_blank' href='http://lamtakam.com/img/post/imageGenerator.php?tc=17&id=321780&t=%D8%B3%D9%84%D8%A7%D9%85'>show</a>
See? It is a <a>
tag which contains the URL of an image. That’s why I’ve set itemprop='image'
to it and fortunately, Google detects it as well.
All I want to know, how can I also set a text to that image? Something like alt
attribute?
2
Answers
You can’t.
<a>
elements are containers, not replaced content. There don’t have any intrinsic content to show an alternative to.As @Quentin points out, you cannot use
<a>
in this way.You can however wrap
<a></a>
around<img>
. For example you can useNotice the
rel='noopener noreferrer'
in there? If you usetarget='_blank'
you should userel='noopener noreferrer'
to prevent the phishing attack called reverse tabnabbing.