I'd like to know the difference between title attr of the tag "a" and alt attr of the tag img.
Also, which should I use when I have an image inside an a? Just like in this case:
<a class="duplicar" href="#"><img src="Images/btnSegDuplicar.gif" alt ="Duplicar" width="76" height="20" /></a>
Right now, as you can see, I'm using the alt but I'm having a little issue. No matter the browser in my development server the tooltips is shown, but in my production server it is not. I tried using both of them (alt and title) and it worked, but it is kind of ugly. Why is that difference between both servers?
Use document. getElementById('theImage'). title='tooltip text' .
The <img> tag has two required attributes: src - Specifies the path to the image. alt - Specifies an alternate text for the image, if the image for some reason cannot be displayed.
Tip: To create a tooltip for an image, use the title attribute!
Images can be easily inserted at any section in an HTML page. To insert image in an HTML page, use the <img> tags. It is an empty tag, containing only attributes since the closing tag is not required. Just keep in mind that you should use the <img> tag inside <body>…
You should always use the title
attribute for tooltips. With images as well as with anchors.
The alt
attribute is solely for the purpose of displaying a text when the image can not be viewed for some reason. That this text is sometimes shown as a tooltip is an incidental artifact of some implementations, and by no means a part of its specification.
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