为什么不鼓励按钮导航? [英] Why are button's discouraged from navigation?

查看:14
本文介绍了为什么不鼓励按钮导航?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

This may be an opinionated question, but I was looking around the web and it seems like web developers like to style <a> tags to look like buttons, rather than use a specific <button> tag. I've noticeably seen this when looking at navigations

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

After a bit of research, I found this:

  • 按钮不适合搜索,因为其中的文本对搜索引擎是不可见的.
  • 按钮比链接更难更新,每次更新都需要 Photoshop 和新图片.
  • 按钮加载速度比链接慢,这对移动访问者尤其不利.
  • 视觉障碍者不太容易使用按钮.
  • 按钮是不必要的,即使你想使用非标准字体,这要归功于 TypeKit 等工具.~ 引用自这里

但是,这些原因"中的大多数似乎都非常站不住脚,并且您需要 photoshop"之类的答案似乎……嗯……无效?

However, most of these 'reasons' seems quite flimsy and answers like 'you need photoshop' seem... well... invalid?

所以我想知道:

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

Is there an actual reason why the <button> tags aren't used when creating navigation menus, and instead style <a> tags to look like buttons? Why aren't buttons the norm? Is this not what they're made for?

* 我不希望你在这里发表意见,也不希望有观点.仅关于为什么会这样的事实信息

推荐答案

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

After reading up on multiple documents posted in the comments, it seems that there is actually a clear factual reason buttons are not used in navigation bars.

当存在页面重定向或将用户带到网站的其他位置时使用这些.

These are used when there is a page redirect or taking a user elsewhere on the website.

  • 如果它导航,它就是一个链接.使用具有有效超文本引用的链接标记

~链接不是按钮

按钮元素

当您想要doSomething() 重定向用户时使用这些.IE.提交表单/等.

Button elements

These are used when you want to doSomething() that is not redirecting the user. I.e. submitting a form / etc.

你需要问自己的问题是:

The question you need to ask yourself is:

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

Will this control be used to initiate an immediate action or Is the action to navigate to another page?

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

if the answer to your question is the first part, then you should be using a button element. Whereas if it is the latter that you are wishing to do, then you should be using an a element.

进一步阅读:

链接不是按钮.DIV 和 SPAN 也不是

何时使用按钮元素

这篇关于为什么不鼓励按钮导航?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆