nhalink
nhalink

Reputation: 513

How to implement title-attribute on linking image

I was wondering what is the best way to implement the title and alt on a linking image.

An img-tag can have both the title and alt attributes, an a-tag can only have the title attribute. When linking an image what is the best way to implement the title-attribute? Should I put it on both the img and a-tag or just one of the two?

Upvotes: 2

Views: 335

Answers (1)

Bastian Rang
Bastian Rang

Reputation: 2187

they have a different approach. the title-attribute adds a description to the element, the alt-attribute behaves as an alternative textual presentation of a image.

<a href="..." title="Click here for more information about VanGogh">
    <img src="vangogh.png" alt="Famous painting of VanGogh" />
</a>

Upvotes: 1

Related Questions