skip to Main Content

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.

enter image description here

All I want to know, how can I also set a text to that image? Something like alt attribute?

2

Answers


  1. You can’t. <a> elements are containers, not replaced content. There don’t have any intrinsic content to show an alternative to.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search