Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
262 views
in Technique[技术] by (71.8m points)

html - <button>与</button> <button><input type=“button” /></button> <button>。</button> <button>使用哪个?</button>(<button> vs. <input type=“button” />. Which to use?)

When looking at most sites (including SO), most of them use:

(查看大多数站点(包括SO)时,大多数使用:)

<input type="button" />

instead of:

(代替:)

<button></button>
  • What are the main differences between the two, if any?

    (两者之间的主要区别是什么?)

  • Are there valid reasons to use one instead of the other?

    (是否有正当理由使用一个而不是另一个?)

  • Are there valid reasons to use combine them?

    (是否有使用它们的有效理由?)

  • Does using <button> come with compatibility issues, seeing it is not very widely used?

    (使用<button>是否存在兼容性问题,看到它没有被广泛使用?)

  ask by Aron Rotteveel translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • Here's a page describing the differences (basically you can put html into a <button></button> )

    (这是描述差异的页面 (基本上,您可以将html放入<button></button> ))

  • And another page describing why people avoid <button></button> (Hint: IE6)

    (另一页描述了人们为什么避免使用<button></button> (提示:IE6))

Another IE problem when using <button /> :

(使用<button />时的另一个IE问题:)

And while we're talking about IE, it's got a couple of bugs related to the width of buttons.

(在谈论IE的同时,还有一些与按钮宽度有关的错误。)

It'll mysteriously add extra padding when you're trying to add styles, meaning you have to add a tiny hack to get things under control.

(当您尝试添加样式时,它将神秘地添加额外的填充,这意味着您必须添加一个小技巧才能使事情得到控制。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...