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?
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 use
<a itemprop='image' target='_blank' rel='noopener noreferrer' href='http://lamtakam.com/img/post/imageGenerator.php?tc=17&id=321780&t=%D8%B3%D9%84%D8%A7%D9%85'><img src='example-image.gif' alt='Example image' height='42' width='42'></a>
Notice the rel='noopener noreferrer'
in there? If you use target='_blank'
you should use rel='noopener noreferrer'
to prevent the phishing attack called reverse tabnabbing .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.