HTMLButtonElement

button 要素 (HTML)

[4] HTMLbutton 要素は、 ボタン制御子を作成します。

[5] 仕様書:

  1. HTML 4 (Web Forms 1.0)
  2. XHTML 1.0

[6]

状態
W3C 勧告
名前空間URI
http://www.w3.org/1999/xhtml
局所名
button (button (ボタン) より)
開始タグ
必須
終了タグ
必須
内容模型
(%flow;)* −(a | %formctrl; | form | fidleset | isindex | iframe | 画像写像)
出現できる文脈
%formctrl な文脈 (歴史的変遷: https://suika.suikawiki.org/www/2004/html/content-button)

属性

[20]
accesskey%Character[HTML 4]
class[HTML 4] %coreattrs
datafldデータ欄名[HTML 4] 予約
dataformatasplaintextデータ書式[HTML 4] 予約
datasrc%URIデータ源[HTML 4] 予約
dir書字方向[HTML 4] %i18n
disabled(真偽値属性)()無効[HTML 4]
dojotype非標準Dojo
id一意識別子[HTML 4] %coreattrs
lang自然言語[HTML 4] %i18n
xml:lang自然言語[XHTML 1]
name制御子名[HTML 4]
onblur%Script失焦点時[HTML 4]
onclick[HTML 4] %events
ondblclick[HTML 4] %events
onfocus%Script得焦点時[HTML 4]
onkeydown[HTML 4] %events
onkeypress[HTML 4] %events
onkeyup[HTML 4] %events
onmousedown[HTML 4] %events
onmousemove[HTML 4] %events
onmouseout[HTML 4] %events
onmouseover[HTML 4] %events
onmouseup[HTML 4] %events
styleスタイル情報[HTML 4] %coreattrs
tabindexNUMBERタブ順[HTML 4]
title注釈的題[HTML 4] %coreattrs
typesubmitボタン種[HTML 4]
value提出ボタン初期値[HTML 4]

内容

[7] 内容はボタンの (ラベル) になります。

[2] button 要素の子孫に画像写像を入れることは違法です HTML 4 17.5

[3] button 要素の子孫に input, select, textarea, button, isindex, label, form, fieldset, iframe 各要素は存在できません。 XHTML 1.0

[37] op (独自XML名前空間)

処理

[8] 視覚 UA は、 button の周りに起伏をつけてレンダリングして、 かちっにあわせて上下させて構いません。対して input によるボタンは平らな画像にレンダリングして構いません。 HTML 4 17.5

HTMLButtonElement インターフェイス

[18] Node, Element, HTMLElement

createTextRangeHTMLButtonElement (WinIE 4)
formHTMLButtonElement (WinIE 4)
nameHTMLButtonElement (WinIE 4)
onresizeHTMLButtonElement (WinIE 4)
statusHTMLButtonElement (WinIE 4)
typeHTMLButtonElement (WinIE 4)
valueHTMLButtonElement (WinIE 4)

関連

[1] ボタン制御子は、 button 要素型だけではなく、 input 要素型でも、 type 属性を submitresetbutton と指定することで作成できます。

両要素型の違いは、歴史的事情 (古い UA は button に対応していない。) と札の指定の柔軟性 (input では札は value 属性値と同じ。) です。

[9] 絵つきボタンの例 HTML 4 17.5

 <FORM action="http://somesite.com/prog/adduser" method="post">
    <P>
    First name: <INPUT type="text" name="firstname"><BR>
    Last name: <INPUT type="text" name="lastname"><BR>
    email: <INPUT type="text" name="email"><BR>
    <INPUT type="radio" name="sex" value="Male"> Male<BR>
    <INPUT type="radio" name="sex" value="Female"> Female<BR>
    <BUTTON name="submit" value="submit" type="submit">
    Send<IMG src="/icons/wow.gif" alt="wow"></BUTTON>
    <BUTTON name="reset" type="reset">
    Reset<IMG src="/icons/oops.gif" alt="oops"></BUTTON>
    </P>
 </FORM>

この例は、代替文が不適切だと考えられます。 非図形的 UA では例えば Send{wow} のような意味不明な表示になってしまいます。

[14]

<a href="intr/metal.mpg"><button type="button" name="video" value="push"  style="color=#FFFFFF; background-color: #FFFFCC; font-weight: bold;">
<p align="center">
<font size="3">金属工学科紹介ビデオ<br>(mpeg, 91.6MB)</font>
</button></a>
</p>

リンクボタン風にしたかったのでしょうか・・・。

メモ

[10] 提出ボタン (submit) についてはフォームの提出input//submitinput//image の説明、 再設定ボタン (reset) についてはフォームの再設定input//reset の説明、 押しボタンについては input/button の説明も参照してください。

[11] 猫式Webメモ http://d.hatena.ne.jp/nekoshiki/20040601#p1

押すか押さないかに関わらず全てのボタンに割り当てられたフォームデータを送信してしまう。

[12] Reread : IE の button 要素の扱いがあまりに酷い件 http://text.readalittle.net/article.php?id=81 (名無しさん [sage])

[13] 2005/02/19 自宅 「<button> と MSIE の関係に疲れ果てる」 (2005-02-21 23:21:32 +09:00 版) http://fromto.cc/hosokawa/diary/2005/20050219-home/ (名無しさん)

[15] HTML5 IRC logs: freenode / #whatwg / 20070414 (2007-04-14 17:00:39 +09:00 版) http://krijnhoetmer.nl/irc-logs/whatwg/20070414#l-140 (名無しさん 2007-04-14 08:26:11 +00:00)

[16] Particletree &#187; Rediscovering the Button Element ( 版) http://particletree.com/features/rediscovering-the-button-element/ (名無しさん 2007-05-17 11:20:23 +00:00)

button 要素 type 属性 (HTML, XHTML 1)

[73] HTMLbutton 要素の type 属性は、ボタンの型を指定します。

[74] 仕様書:

属性値

[75] この属性は列挙型です。

属性値説明出典
button押しボタン[HTML 4]
reset再設定ボタン[HTML 4]
submit提出ボタン[HTML 4]

[76] この属性は省略可能です。省略時の既定値は submit です。

実装

[78] Index of /~wakaba/-temp/test/dom/html-button-element/type ( 版) https://suika.suikawiki.org/~wakaba/-temp/test/dom/html-button-element/type/

[79] type DOM属性に値を設定 (set-1.html): FirefoxOpera は PASS。WinIE7 は値を設定するところで実行時エラーSafari 3.2.1 と Chrome 0.4.154.29 はエラーにはならないが、属性値は変化しない。

[80] setAttribute を使って type 内容属性に値を設定 (set-attribute-1.html): 全ブラウザ PASS。

メモ

[77] input 要素の type 属性 と値をあわせたのでしょうが、 <button type="button"> というのは格好が悪い。

[81] [CITE@@en[Web Applications 1.0 r5293 Forgot to remove <button> from the main scoping list. Please let me know ASAP if this change breaks anything.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10223]] ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5292&to=5293

[82] [whatwg] Alignment of empty buttons ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/040046.html

[83] XML Binding Language (XBL) 2.0 ( ( 版)) http://www.w3.org/TR/2007/CR-xbl-20070316/#button

[84] 1089326 – event.target refers to parent BUTTON instead of clicked IMG when IMG is child of BUTTON (Selecting different views of the product is not possible in www.myntra.com) ( ( 版)) https://bugzilla.mozilla.org/show_bug.cgi?id=1089326

[17] Remove the concept of CSS Bindings (annevk著, ) https://github.com/whatwg/html/commit/6c96beabfa41d6d28ab23633966b82c5cdb9fd94

[19] Remove <button type=menu> (domenic著, ) https://github.com/whatwg/html/commit/916e1b9f6bea48cb117ddd056ea025adaa629384

[21] <a>か<button>か - hitode909の日記 () http://blog.sushi.money/entry/2017/12/07/141717

[22] Fix form inheritance behavior for autocapitalize (rlanday著, ) https://github.com/whatwg/html/commit/b7c21b1b56d77215d3d85ae14a072c090dbe6266

[23] Editorial: always state invalid value default (GloverDonovan著, ) https://github.com/whatwg/html/commit/7e941ae96b264d4743ea0afac00c3b3209ab0cde

[24] Queue a task to run all the autofocusing steps (domenic著, ) https://github.com/whatwg/html/commit/185190cac859144cfcd78248b906f3adae1f0594

[25] <button> should be transparent content model like <a> · Issue #3765 · whatwg/html () https://github.com/whatwg/html/issues/3765

[26] Define button layout (zcorpan著, ) https://github.com/whatwg/html/commit/6780c22fccb41f5d84aa079d2644c79b1acdc5eb

[27] Define that button text is centered vertically · Issue #1024 · whatwg/html () https://github.com/whatwg/html/issues/1024

[28] HTML spec is unclear about how buttons are sized in non-inline contexts (and browsers disagree) · Issue #2948 · whatwg/html () https://github.com/whatwg/html/issues/2948

[29] Rendering rules for buttons · Issue #4081 · whatwg/html () https://github.com/whatwg/html/issues/4081

[30] Default 'display' value for form controls · Issue #4082 · whatwg/html () https://github.com/whatwg/html/issues/4082

[31] 962936 - Implement button layout per HTML rendering spec - chromium - An open-source project to help move the web forward. - Monorail () https://bugs.chromium.org/p/chromium/issues/detail?id=962936

[32] 197879 – Implement button layout per HTML rendering spec () https://bugs.webkit.org/show_bug.cgi?id=197879

[33] 1539469 - Make <input> elements display: inline-block by default (was: Fix WPT: testing/web-platform/tests/html/semantics/forms/the-input-element/input-width.html) () https://bugzilla.mozilla.org/show_bug.cgi?id=1539469

[34] Define button layout by zcorpan · Pull Request #4143 · whatwg/html () https://github.com/whatwg/html/pull/4143

[35] Do not inherit text-transform (et al.) on form controls (jugglinmike著, ) https://github.com/whatwg/html/commit/b9997b7488a3b35515c30bb1627d361053cf2c2f

[36] Define what tabIndex returns when the tabindex attribute is not set (rakina著, ) https://github.com/whatwg/html/commit/15cf23a55d629e0b1286302c19634833a89292ab