I wanted to know if adding a 'title' attribute is semantic relevant on a 'img' tag. I already always use the 'alt' attribute to respec the W3C spec.
And if yes, is the content on the 'title' attribute have to be different from the 'alt' one ?
The title
attribute can be used as semantic, i.e. as relating to meaning. As such, it is defined to be an advisory title, and browsers may make its value optionally available to users, e.g. as a tooltip on mouseover or as a cue spoken by a speech browser. This means that it can be used for a multitude of purposes, semantic or other. It is up to you to decide whether you use it to describe the meaning of the image, or to give authorship information, or e.g. just to show a name for the image (the name may or may not describe the meaning).
Search engines may treat the title
text as relating to the image, possibly causing a page to appear in image searches when words appearing in that text are used. The details of such processing have not been disclosed and probably vary from one search engine to another.
There is no reason why the value of the title
attribute should not be the same as the value of the alt
attribute. They have different purposes, but sometimes the same text can serve both. For example, if the image contains a person’s signature, the alt
attribute should probably contain just the name in the signature, and the title
attribute could contain the same (e.g., to help people who can see the image but cannot read the name easily), or it could be more explanatory, e.g. title="Joe Q. Public (signature)"
.
Just to expand a little about what @SLaks said in their answer. The title
attribute can also help with SEO and expressing more about what a web page has to offer. Just a tid bit to add is all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With