Is it correct to use alt tag for an anchor link, something like
<a href="#" class="test" alt="Something" src="sfasfs" ></a>
The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link's destination. By default, links will appear as follows in all browsers: An unvisited link is underlined and blue.
In order for a link to be readable by screen reader users links must all contain either plain text, or in the case of a linked image, alt text describing where the link goes.
Such things are best answered by looking at the official specification:
go to the specification: https://www.w3.org/TR/html5/
search for "a
element": https://www.w3.org/TR/html5/text-level-semantics.html#the-a-element
check "Content attributes", which lists all allowed attributes for the a
element:
- Global attributes
href
target
download
rel
hreflang
type
check the linked "Global attributes": https://www.w3.org/TR/html5/dom.html#global-attributes
As you will see, the alt
attribute is not allowed on the a
element.
Also you’d notice that the src
attribute isn’t allowed either.
By validating your HTML, errors like these are reported to you.
Note that the above is for HTML5, which is W3C’s HTML standard from 2014. In 2016, HTML 5.1 became the next HTML standard. Finding the allowed attributes works in the same way. You’ll see that the a
element can have another attribute in HTML 5.1: rev
.
You can find all HTML specifications (including the latest standard) on W3C’s HTML Current Status.
For anchors, you should use title instead. alt is not valid atribute of a. See http://w3schools.com/tags/tag_a.asp
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