将alt标签用于锚链接是否正确? [英] Is it correct to use alt tag for an anchor link?
问题描述
将alt标签用于锚链接是正确的,例如
< a href =#class =testalt =Somethingsrc =sfasfs>< / a>
通过查看官方规范:
-
搜索
a
element: https://www.w3。 org / TR / html5 / text-level-semantics.html#元素
-
勾选内容属性,列出所有允许
a 元素的属性:
- 全局属性
-
href
-
目标
-
下载
-
rel
-
hreflang
-
类型
-
检查链接的全局属性: https://www.w3.org/TR/html5/dom.html#global-attributes
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-elementcheck "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
ol>
正如您将看到的, alt
属性不允许位于 a
元素。
您也会注意到 src
属性也是不允许的。
通过验证您的HTML ,会向您报告类似的错误。
请注意,以上是 HTML5 ,它是 W3C的HTML标准从2014年开始。 2016年, HTML 5.1 成为下一个HTML标准。查找允许的属性以相同的方式工作。您会发现 a
元素在HTML 5.1中可以有另一个属性: rev
。
您可以在 W3C的 HTML电流中找到所有HTML规范(包括最新标准)状态 。
Is it correct to use alt tag for an anchor link, something like
<a href="#" class="test" alt="Something" src="sfasfs" ></a>
Such things are best answered by looking at the official specification:
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.
这篇关于将alt标签用于锚链接是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!