html href元素中标题和名称之间的区别

Bel*_*ish 5 html href title

在HTML的href中,使用之间有什么区别

<a href="http://www.somesite.com/" name="The Name">
Run Code Online (Sandbox Code Playgroud)

<a href="http://www.somesite.com/" title="The Name">
Run Code Online (Sandbox Code Playgroud)

使用一个相对于另一个有什么好处吗?

谢谢

Geo*_*ian 4

在规范中查找它,或者更好的是稍微压缩规范的资源。(如果这还不够,那么还有规范。)

title   text    Specifies extra information about an element
Run Code Online (Sandbox Code Playgroud)

http://www.w3schools.com/tags/tag_a.asp

name 属性指定锚点的名称。

name 属性用于在文档内创建书签。

href 或 name 属性必须出现在标签中

http://www.w3schools.com/tags/att_a_name.asp

因此,锚点的名称用于类似 的链接exampledomain.com/index.php#some_section,这将使该锚点成为页面的焦点。

当鼠标悬停在链接上时,许多现代浏览器会在工具提示中显示标题属性。它可能对于屏幕阅读器等也很有用。