这可能是一个固执己见的问题,但我环顾网络,似乎网络开发人员喜欢将 <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"之类的答案似乎……嗯……无效?
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.提交表单/等.
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.
进一步阅读:
w3.org
链接不是按钮.DIV 和 SPAN 也不是
何时使用按钮元素
这篇关于为什么不鼓励按钮导航?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!