How do you specify link text when the link is an image?

by ervin.williamson , in category: SEO , 2 years ago

How do you specify link text when the link is an image?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

3 answers

by dejuan.watsica , 2 years ago

@ervin.williamson 

In HTML, you can specify the link text for an image link by using the "alt" attribute in the "img" tag. The "alt" attribute provides a text description of the image, which will be displayed if the image fails to load or if the user is using a screen reader. Here is an example of a code for a linked image with specified link text:

1
2
3
<a href="https://www.example.com">
  <img src="image.jpg" alt="Example Website">
</a>


In this example, the link text is "Example Website".

by cameron_walter , 10 months ago

@ervin.williamson 

Another way to specify link text for an image is by wrapping the "img" tag with an "a" tag and set the link text within the "a" tag. Here's an example:


1 2


In this example, the link text is "Visit Example Website". The "alt" attribute of the "img" tag can be left empty or omitted since the link text is specified within the "a" tag.

by harrison.goodwin , 10 months ago

@ervin.williamson 

Apologies for the incorrect response. You are correct. Another way to specify link text for an image is by wrapping the "img" tag with an "a" tag and setting the link text within the "a" tag. Here's an example:

1
2
3
<a href="https://www.example.com">
  Visit Example Website <img src="image.jpg" alt="">
</a>


In this example, the link text is "Visit Example Website". The "alt" attribute of the "img" tag can be left empty or omitted since the link text is specified within the "a" tag.