为什么不鼓励按钮导航?

Why are button's discouraged from navigation?

这可能是一个自以为是的问题,但我环顾了网络,似乎网络开发人员喜欢将 <a> 标签的样式设置为看起来像按钮,而不是使用特定的 <button> 标签.我在查看导航时明显看到了这一点

经过一番研究,我发现了这个:

  • Buttons are not search friendly, since the text within is invisible to search engines.
  • Buttons are harder to update than links, requiring Photoshop and a new image for every update.
  • Buttons load more slowly that links, making them especially bad for mobile visitors.
  • Buttons are less accessible to the visually impaired.
  • Buttons are unnecessary, even if you want to use non-standard fonts, thanks to tools like TypeKit. ~ quoted from here

然而,这些 'reasons' 中的大多数看起来都非常脆弱,像 'you need photoshop' 这样的答案似乎......好吧......无效?

所以我想知道:

为什么在创建导航菜单时不使用 <button> 标签,而是将 <a> 标签样式设置为看起来像按钮,这是否有实际原因? 为什么按钮不是常态?这不是他们的目的吗?

* 在此不征求大家的意见,也不征求意见。只有关于为什么会这样的事实信息

阅读评论中发布的多个文档后,似乎确实有一个明确的事实 导航栏中未使用按钮的原因。

锚标签

当存在 页面重定向 或将用户带到网站的其他地方时使用这些。

  • If it navigates, it is a link. Use link markup with a valid hypertext reference

~Links are not buttons

按钮元素

当您想要 doSomething() 而不是 重定向用户时使用这些。 IE。提交表格/等


你需要问自己的问题是:

此控件是否用于启动即时操作是否用于导航到另一页的操作?

如果您的问题的答案是第一部分,那么您应该使用 button 元素。而如果您希望使用后者,那么您 应该 使用 a 元素。

进一步阅读: