< a>与< button>与< div> vs<输入类型=“按钮"> [英] <a> vs <button> vs <div> vs <input type='button">

查看:69
本文介绍了< a>与< button>与< div> vs<输入类型=“按钮">的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过很多关于我想一个特定情况的我的一个特定情况"的帖子. HTML中的按钮.

I've seen so many posts along the lines of "I'd like to one-specific-thing for my one-specific-situation when it comes to buttons in HTML.

如果可以的话,我想在这里发表一篇专业的文章:

If I may, I'd like to get a professional take all in one post, here:

在HTML中制作按钮时,什么情况会导致以下情况:

When making buttons in HTML, what situations lead to:

  • <a>是最好的答案?
  • <button>是最好的答案?
  • <div>是最好的答案?
  • <input type='button'>是最好的答案?
  • <a> being the best answer?
  • <button> being the best answer?
  • <div> being the best answer?
  • <input type='button'> being the best answer?

推荐答案

好文章 很好地总结了差异

There's a good article that summarizes the differences nicely

简而言之:

|                       |       General usage        | Complex designs | Can be disabled |
|-----------------------|----------------------------|-----------------|-----------------|
| <button>              | General button purpose.    | Yes             | Yes             |
|                       | Used in most cases         |                 |                 |
| --------------------- | -------------------------- | --------------- | --------------- |
| <input type="button"> | Usually used inside        | No              | Yes             |
|                       | forms                      |                 |                 |
| --------------------- | -------------------------- | --------------- | --------------- |
| <a>                   | Used to navigate to        | Yes             | No              |
|                       | pages and resources        |                 |                 |
| --------------------- | -------------------------- | --------------- | --------------- |
| <div>                 | Can be used for clickable  | Yes             | No              |
|                       | area which is not button   |                 |                 |
|                       | or link by definition      |                 |                 |

这篇关于&lt; a&gt;与&lt; button&gt;与&lt; div&gt; vs&lt;输入类型=“按钮"&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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