1.仕様
BUTTON要素は、
その内容によって
ラベル付けされたボタンを
表します。
- button
-
押すボタン (push button)
- 種類
-
通常要素
- カテゴリ
-
- フロー
コンテンツ - フレージング
コンテンツ - インタラクティブ
コンテンツ - リストされた
要素 - ラベル付け可能な
要素 - 送信可能な
要素 - 自動
大文字化 継承 要素 - フォーム
関連要素 - パルパブル
コンテンツ
- フロー
- 使用できるコンテキスト
-
フレージング
コンテンツ を受け入れる要素フレージング
コンテンツ を受け入れる要素のコンテンツとして、使用できます。フレージング
コンテンツ を受け入れる要素は、h1要素 , h2要素 , h3要素 , h4要素 , h5要素 , h6要素 , p要素 , pre要素 , output要素 , progress要素 , meter要素 , label要素 , datalist要素 , body要素 , section要素 , nav要素 , aside要素 , article要素 , header要素 , footer要素 , main要素 , address要素 , li要素 , dt要素 , dd要素 , caption要素 , th要素 , td要素 , form要素 , fieldset要素 , search要素 , blockquote要素 , figure要素 , figcaption要素 , div要素 , dialog要素 , abbr要素 , b要素 , bdi要素 , bdo要素 , cite要素 , code要素 , data要素 , dfn要素 , em要素 , i要素 , kbd要素 , mark要素 , q要素 , s要素 , samp要素 , small要素 , span要素 , strong要素 , sub要素 , sup要素 , u要素 , var要素 です。 - コンテンツモデル
-
0個以上のフレージング
コンテンツ (インタラクティブコンテンツ を除く)0個以上のフレージング
コンテンツ が配置できます。ですが、インタラクティブコンテンツ は子孫に持てません。インタラクティブ
コンテンツ を除くフレージングコンテンツ に分類される要素は、script要素 , noscript要素 , template要素 , input要素 , output要素 , progress要素 , meter要素 , datalist要素 , picture要素 , object要素 , img要素 , video要素 , audio要素 , canvas要素 , map要素 , area要素 , a要素 , ins要素 , del要素 , abbr要素 , b要素 , bdi要素 , bdo要素 , cite要素 , code要素 , data要素 , dfn要素 , em要素 , i要素 , kbd要素 , mark要素 , q要素 , s要素 , samp要素 , small要素 , span要素 , strong要素 , sub要素 , sup要素 , u要素 , var要素 , time要素 , ruby要素 , br要素 , wbr要素 , slot要素 , テキスト です。インタラクティブコンテンツの子孫や tabindex属性が指定された子孫があってはなりません。
- タグの省略
-
どちらのタグも省略できません。
- コンテンツ属性
-
グローバル属性 他
- disabled
属性 - フォームコントロールが無効かどうか
- form
属性 - 要素をフォーム要素に関連付けます
- formaction
属性 - フォーム送信に使用するURL
- formenctype
属性 - フォーム送信に使用するエントリリストのエンコードタイプ
- formmethod
属性 - フォーム送信に使用するHTTPメソッド
- formnovalidate
属性 - フォーム送信時のフォームコントロールの検証をバイパスする
- formtarget
属性 - フォーム送信にナビゲート可能
- name
属性 - フォーム送信および form.elements API で使用する要素の名前
- popovertarget
属性 - ポップオーバー要素を切り替え、表示、または非表示にする対象とします。
- popovertargetaction
属性 - ターゲットのポップオーバー要素を切り替えるか、表示するか、非表示にするかを示します。
- type
属性 - ボタンの種類
- value
属性 - フォーム送信に使用される値
- disabled
- DOM インターフェイス
-
HTMLButtonElement
[Exposed=Window]
interface HTMLButtonElement : HTMLElement {
[HTMLConstructor] constructor();
[CEReactions] attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[CEReactions] attribute USVString formAction;
[CEReactions] attribute DOMString formEnctype;
[CEReactions] attribute DOMString formMethod;
[CEReactions] attribute boolean formNoValidate;
[CEReactions] attribute DOMString formTarget;
[CEReactions] attribute DOMString name;
[CEReactions] attribute DOMString type;
[CEReactions] attribute DOMString value;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();
undefined setCustomValidity(DOMString error);
readonly attribute NodeList labels;
};
HTMLElement
[Exposed=Window]
interface HTMLElement : Element {
[HTMLConstructor] constructor();
// metadata attributes
[CEReactions] attribute DOMString title;
[CEReactions] attribute DOMString lang;
[CEReactions] attribute boolean translate;
[CEReactions] attribute DOMString dir;
// user interaction
[CEReactions] attribute (boolean or unrestricted double or DOMString)? hidden;
[CEReactions] attribute DOMString inert;
undefined click();
[CEReactions] attribute DOMString accessKey;
readonly attribute DOMString accessKeyLabel;
[CEReactions] attribute boolean draggable;
[CEReactions] attribute boolean spellcheck;
[CEReactions] attribute DOMString writingSuggestions;
[CEReactions] attribute DOMString autocapitalize;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString outerText;
ElementInternals attachInternals();
// The popover API
undefined showPopover();
undefined hidePopover();
boolean togglePopover(optional boolean force);
[CEReactions] attribute DOMString? popover;
};
HTMLElement includes GlobalEventHandlers;
HTMLElement includes ElementContentEditable;
HTMLElement includes HTMLOrSVGElement;
Element
[Exposed=Window]
interface Element : Node {
readonly attribute DOMString? namespaceURI;
readonly attribute DOMString? prefix;
readonly attribute DOMString localName;
readonly attribute DOMString tagName;
[CEReactions] attribute DOMString id;
[CEReactions] attribute DOMString className;
[SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
[CEReactions, Unscopable] attribute DOMString slot;
boolean hasAttributes();
[SameObject] readonly attribute NamedNodeMap attributes;
sequence<DOMString> getAttributeNames();
DOMString? getAttribute(DOMString qualifiedName);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
[CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
[CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
[CEReactions] undefined removeAttribute(DOMString qualifiedName);
[CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
[CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
boolean hasAttribute(DOMString qualifiedName);
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
Attr? getAttributeNode(DOMString qualifiedName);
Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName);
[CEReactions] Attr? setAttributeNode(Attr attr);
[CEReactions] Attr? setAttributeNodeNS(Attr attr);
[CEReactions] Attr removeAttributeNode(Attr attr);
ShadowRoot attachShadow(ShadowRootInit init);
readonly attribute ShadowRoot? shadowRoot;
Element? closest(DOMString selectors);
boolean matches(DOMString selectors);
boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches
HTMLCollection getElementsByTagName(DOMString qualifiedName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy
undefined insertAdjacentText(DOMString where, DOMString data); // legacy
};
GlobalEventHandlers
interface mixin GlobalEventHandlers {
attribute EventHandler onabort;
attribute EventHandler onauxclick;
attribute EventHandler onbeforeinput;
attribute EventHandler onbeforematch;
attribute EventHandler onbeforetoggle;
attribute EventHandler onblur;
attribute EventHandler oncancel;
attribute EventHandler oncanplay;
attribute EventHandler oncanplaythrough;
attribute EventHandler onchange;
attribute EventHandler onclick;
attribute EventHandler onclose;
attribute EventHandler oncontextlost;
attribute EventHandler oncontextmenu;
attribute EventHandler oncontextrestored;
attribute EventHandler oncopy;
attribute EventHandler oncuechange;
attribute EventHandler oncut;
attribute EventHandler ondblclick;
attribute EventHandler ondrag;
attribute EventHandler ondragend;
attribute EventHandler ondragenter;
attribute EventHandler ondragleave;
attribute EventHandler ondragover;
attribute EventHandler ondragstart;
attribute EventHandler ondrop;
attribute EventHandler ondurationchange;
attribute EventHandler onemptied;
attribute EventHandler onended;
attribute OnErrorEventHandler onerror;
attribute EventHandler onfocus;
attribute EventHandler onformdata;
attribute EventHandler oninput;
attribute EventHandler oninvalid;
attribute EventHandler onkeydown;
attribute EventHandler onkeypress;
attribute EventHandler onkeyup;
attribute EventHandler onload;
attribute EventHandler onloadeddata;
attribute EventHandler onloadedmetadata;
attribute EventHandler onloadstart;
attribute EventHandler onmousedown;
[LegacyLenientThis] attribute EventHandler onmouseenter;
[LegacyLenientThis] attribute EventHandler onmouseleave;
attribute EventHandler onmousemove;
attribute EventHandler onmouseout;
attribute EventHandler onmouseover;
attribute EventHandler onmouseup;
attribute EventHandler onpaste;
attribute EventHandler onpause;
attribute EventHandler onplay;
attribute EventHandler onplaying;
attribute EventHandler onprogress;
attribute EventHandler onratechange;
attribute EventHandler onreset;
attribute EventHandler onresize;
attribute EventHandler onscroll;
attribute EventHandler onscrollend;
attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
attribute EventHandler onslotchange;
attribute EventHandler onstalled;
attribute EventHandler onsubmit;
attribute EventHandler onsuspend;
attribute EventHandler ontimeupdate;
attribute EventHandler ontoggle;
attribute EventHandler onvolumechange;
attribute EventHandler onwaiting;
attribute EventHandler onwebkitanimationend;
attribute EventHandler onwebkitanimationiteration;
attribute EventHandler onwebkitanimationstart;
attribute EventHandler onwebkittransitionend;
attribute EventHandler onwheel;
};
ElementContentEditable
interface mixin ElementContentEditable {
[CEReactions] attribute DOMString contentEditable;
[CEReactions] attribute DOMString enterKeyHint;
readonly attribute boolean isContentEditable;
[CEReactions] attribute DOMString inputMode;
};
HTMLOrSVGElement
interface mixin HTMLOrSVGElement {
[SameObject] readonly attribute DOMStringMap dataset;
attribute DOMString nonce; // intentionally no [CEReactions]
[CEReactions] attribute boolean autofocus;
[CEReactions] attribute long tabIndex;
undefined focus(optional FocusOptions options = {});
undefined blur();
};
- ARIA in HTML
-
暗黙的="
button
" ARIAロール="あり" aria-* 属性="GlobalAny
"暗黙的な ARIAセマンティクスは、
role=button
です。作成者が要素に指定してもよい ARIAロール値は、 checkbox, combobox, gridcell, link, menuitem, menuitemcheckbox, menuitemradio, option, radio, separator, slider, switch, tab, treeitem です。
グローバル aria-* 属性と、許可されたロールに適用される任意の aria-* 属性が記述できます。
- レンダリング
- インライン
レベル ボックス フォーム
コントロール button {
display: inline-block;
letter-spacing: initial;
word-spacing: initial;
line-height: initial;
text-transform: initial;
text-indent: initial;
text-shadow: initial;
appearance: auto;
text-align: center;
box-sizing: border-box;
}
CSS を大雑把に読むと、 インラインレベルのブロックコンテナボックス(インラインブロック)を生成します。 などになります。
- 説明
-
button
要素 は、その内容によってラベル付けされたボタンを表します。<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"utf-8"> <title>button要素の例 - (Example of button element) | 離珠のHTMLでしぃ!</title>
</head>
<body>
<h1>button要素の例</h1>
<form action=
"../Html/fmreceive.htm"> <input name=
"nipInput" value= "abc"> <button name=
"nbtSender" value= "../Html/exbutton.htm">ボタン</button> <br>受信用の<br>ページへ
</form>
</body>
</html>
このサンプルへのリンクです。
(./exbutton.htm) - 参照元
-
参照元
- HTML Living Standard. 4.10.6 The button element (Last Updated 27 August 2024)
- HTML Living Standard. 15 Rendering 15.3.10 Form controls (Last Updated 27 August 2024)
- HTML Living Standard. 15 Rendering 15.5.3 Button layout (Last Updated 27 August 2024)
- HTML Living Standard. 15 Rendering 15.5.4 The button element (Last Updated 27 August 2024)
- HTML Living Standard. 4.11 Interactive elements 4.11.3.3 Using the button element to define a command (Last Updated 27 August 2024)
- HTML 5.2 W3C 勧告. 4.10.6 The button element (W3C勧告、2017年12月14日)
- HTML 5.2 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2017年12月14日)
- HTML 5.1 W3C 勧告. 4.10.6 The button element (W3C勧告、2016年11月1日)
- HTML 5.1 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2016年11月1日)
- HTML 5 W3C 勧告. 4.10.6 The button element (W3C勧告、2014年10月28日)
- HTML 5 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2014年10月28日)
- HTML 4.01 Specification W3C 勧告. 17.5 The BUTTON element (W3C勧告1999年12月24日)
- <button>: ボタン要素 - HTML: ハイパーテキストマークアップ言語 | MDN
- JSONデータ
-
JSON形式での、データのイメージです。
{
"button": {
"check": "2024-09-01",
"group": "Form",
"element": "- - (%Phrasing)* -(%Interactive) -- push button. (Normal elements.) [Flow|Phrasing|Interactive|Listed|Labelable|Submittable|Autocapitalize|Form|Palpable] --",
"attlist": {
"%Global;": "",
"disabled": "(disabled) #IMPLIED -- Whether the form control is disabled --",
"form": "IDREF #IMPLIED -- Associates the element with a form element --",
"formaction": "%URI; #IMPLIED -- URL to use for form submission --",
"formenctype": "%ContentType; #IMPLIED -- Entry list encoding type to use for form submission --",
"formmethod": "(get|post|dialog) #IMPLIED -- Variant to use for form submission --",
"formnovalidate": "(formnovalidate) #IMPLIED -- Bypass form control validation for form submission --",
"formtarget": "%FrameTarget; #IMPLIED -- Navigable for form submission --",
"name": "CDATA #IMPLIED -- Name of the element to use for form submission and in the form.elements API --",
"popovertarget": "IDREF #IMPLIED -- Targets a popover element to toggle, show, or hide --",
"popovertargetaction": "(toggle|show|hide) #IMPLIED -- Indicates whether a targeted popover element is to be toggled, shown, or hidden --",
"type": "(submit|reset|button) submit -- Type of button --",
"value": "CDATA #IMPLIED -- Value to be used for form submission --",
},
"comment": "押すボタン (push button)",
"point": "その内容によってラベル付けされたボタンを表します。",
"kind": "Normal",
"categories": [
"Flow",
"Phrasing",
"Interactive",
"Listed",
"Labelable",
"Submittable",
"Autocapitalize",
"Formassociated",
"Palpable",
],
"used": "parent (%Phrasing)*",
"contentmodel": "button (%Phrasing)* -(%Interactive)",
"contentmodelsupplement": "インタラクティブコンテンツの子孫や tabindex属性が指定された子孫があってはなりません。",
"tag": [
"-",
"-",
],
"attributes": {
"disabled": "フォームコントロールが無効かどうか",
"form": "要素をフォーム要素に関連付けます",
"formaction": "フォーム送信に使用するURL",
"formenctype": "フォーム送信に使用するエントリリストのエンコードタイプ",
"formmethod": "フォーム送信に使用するHTTPメソッド",
"formnovalidate": "フォーム送信時のフォームコントロールの検証をバイパスする",
"formtarget": "フォーム送信にナビゲート可能",
"name": "フォーム送信および form.elements API で使用する要素の名前",
"popovertarget": "ポップオーバー要素を切り替え、表示、または非表示にする対象とします。",
"popovertargetaction": "ターゲットのポップオーバー要素を切り替えるか、表示するか、非表示にするかを示します。",
"type": "ボタンの種類",
"value": "フォーム送信に使用される値",
},
"dominterface": "HTMLButtonElement",
"rendering": "Form",
"reference": [
{
"title": "HTML Living Standard. 4.10.6 The button element.",
"href": "https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element",
"heading": "HTML Living Standard. 4.10.6 The button element",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML Living Standard. 15 Rendering 15.3.10 Form controls.",
"href": "https://html.spec.whatwg.org/multipage/rendering.html#form-controls",
"heading": "HTML Living Standard. 15 Rendering 15.3.10 Form controls",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML Living Standard. 15 Rendering 15.5.3 Button layout.",
"href": "https://html.spec.whatwg.org/multipage/rendering.html#button-layout",
"heading": "HTML Living Standard. 15 Rendering 15.5.3 Button layout",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML Living Standard. 15 Rendering 15.5.4 The button element.",
"href": "https://html.spec.whatwg.org/multipage/rendering.html#the-button-element-2",
"heading": "HTML Living Standard. 15 Rendering 15.5.4 The button element",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML Living Standard. 4.11 Interactive elements 4.11.3.3 Using the button element to define a command.",
"href": "https://html.spec.whatwg.org/multipage/interactive-elements.html#using-the-button-element-to-define-a-command",
"heading": "HTML Living Standard. 4.11 Interactive elements 4.11.3.3 Using the button element to define a command",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML 5.2 W3C Recommendation. 4.10.6 The button element. W3C Recommendation, 14 December 2017.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/sec-forms.html#the-button-element",
"heading": "HTML 5.2 W3C 勧告. 4.10.6 The button element",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.2 W3C Recommendation. 10.3.11. Form controls.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/rendering.html#form-controls",
"heading": "HTML 5.2 W3C 勧告. 10.3.11. Form controls.",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.1 W3C Recommendation. 4.10.6 The button element. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/sec-forms.html#the-button-element",
"heading": "HTML 5.1 W3C 勧告. 4.10.6 The button element",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 5.1 W3C Recommendation. 10.3.11. Form controls. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/rendering.html#form-controls",
"heading": "HTML 5.1 W3C 勧告. 10.3.11. Form controls.",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 5 W3C Recommendation. 4.10.6 The button element. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-button-element",
"heading": "HTML 5 W3C 勧告. 4.10.6 The button element",
"sub": "W3C勧告、2014年10月28日",
},
{
"title": "HTML 5 W3C Recommendation. 10.3.11. Form controls. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/rendering.html#form-controls",
"heading": "HTML 5 W3C 勧告. 10.3.11. Form controls.",
"sub": "W3C勧告、2014年10月28日",
},
{
"title": "HTML 4.01 Specification W3C Recommendation. 17.5 The BUTTON element. W3C Recommendation 24 December 1999.",
"href": "https://www.w3.org/TR/html401/interact/forms.html#h-17.5",
"heading": "HTML 4.01 Specification W3C 勧告. 17.5 The BUTTON element",
"sub": "W3C勧告1999年12月24日",
},
{
"title": "MDN Web Docs. HTML <button>: The Button element.",
"href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/button",
"heading": "<button>: ボタン要素 - HTML: ハイパーテキストマークアップ言語 | MDN",
},
],
"version": {
"first": "HTML4",
"latest": "HTML Living Standard",
},
}
}
注意: 簡易に描画する為に、各項目の後ろに
,
を付与しています。JSON の形式では、末尾の項目の後には,
は付けません。 - 最終確認日
-
2024-09-01
2.使用可能な箇所
フレージング
受け入れる要素に
配置できます。
button
フレージング
尚 厳密に言うと、コンテンツ
3.配置できるコンテンツ
フレージングコンテンツを
配置できます。
button
フレージング
条件付きでインタラクティブ
tabindexが指定された要素も、子孫にあってはいけません。
4.属性
グローバル属性と、
disabled,
form,
formaction,
formenctype,
formmethod,
formnovalidate,
formtarget,
name,
popovertarget,
popovertargetaction,
type,
value を
設定できます。
buttonは、グローバル属性とdisabled属性, form属性, formaction属性, formenctype属性, formmethod属性, formnovalidate属性, formtarget属性, name属性, popovertarget属性, popovertargetaction属性, type属性, value属性を設定できます。
<form action=
"./fmreceive.htm"> <button>ボタン</button>
<input name=
"nbtSender" type= "hidden" value= "./fobutton.htm#MAP4NEXT"> </form>
form
inputnbtSender
で固定です。
disabled属性
<button disabled>
disabledは、コントロールを非対話型にして、その値が送信されないようにする為に使用されるブール属性です。
form属性
<form action=
"./form.htm"> <button form=
"ifoForm741" >ボタン</button></form>
<form id=
"ifoForm741" action= "./fmreceive.htm"> <input name=
"nbtSender" type= "hidden" value= "./fobutton.htm#MH3FORM"> </form>
formは、入力要素をそのフォーム所有者に明示的に関連付ける為に使用されます。
フォーム関連要素は、デフォルトでは、最も近い祖先form
formaction属性
<form action=
"./form.htm"> <button formaction=
"./fmreceive.htm" >ボタン</button><input name=
"nbtSender" type= "hidden" value= "./fobutton.htm#MH3FORMACTION"> </form>
formactionは、送信されたデータを処理するサービスのURLを表します。
formactionが指定されている場合、その値は、スペースで囲まれた可能性のある有効な空でない URL である必要があります。
要素のアクションは、要素が送信ボタンであり、そのような属性がある場合は要素のformactionの値、フォーム所有者のactionがある場合はその値、ない場合は空の文字列です。
typeがsubmit
の時に、その要素は送信ボタンであり、typeの欠落値のデフォルトと無効な値のデフォルトは、どちらも送信ボタンの状態です。
typeがsubmit
の時に、その要素は送信ボタンであり、typeの欠落値のデフォルトと無効な値のデフォルトは、どちらも送信ボタンの状態です。
formenctype属性
<button formenctype=
"application/ >x-www-form-urlencoded "
formenctypeは、フォーム送信に使用するエントリリストのエンコード
formenctypeが指定されている場合、その値は、次のキーワードと状態です。
- 「application/x-www-form-urlencoded」キーワードと対応する状態。
- 「multipart/form-data」キーワードと対応する状態。
- 「text/plain」キーワードと対応する状態。
列挙属性と呼ばれる一部の属性は、有限の状態セットを取ります。このような属性の状態は、属性の値、各属性の仕様で指定されたキーワード/状態マッピングのセット、および属性の仕様で指定できる 2 つの特殊な状態を組み合わせることによって生成されます。これらの特殊な状態は、無効な値のデフォルトと欠落した値のデフォルトです。
この属性には欠損値のデフォルトはなく、無効値のデフォルトは application/
要素の enctype は、要素が送信ボタンであり、そのような属性がある場合は要素のformenctypeの状態になります。それ以外の場合は、フォーム所有者のenctypeの値(状態)です。
typeがsubmit
の時に、その要素は送信ボタンであり、typeの欠落値のデフォルトと無効な値のデフォルトは、どちらも送信ボタンの状態です。
formmethod属性
<button formmethod=
"get" >
formmethodは、フォーム送信に使用するHTTPメソッドを指定します。
formmethodは、次のキーワード(keywords)と状態(states)を持つ列挙属性(enumerated attribute)です。
- get
- フォームが HTTP GET メソッドを使用することを示します。
- post
- フォームが HTTP POST メソッドを使用することを示します。
- dialog
- フォームが存在するダイアログボックスがあればそれを閉じ、それ以外の場合は送信しないことをフォームが意図していることを示します。
列挙属性と呼ばれる一部の属性は、有限の状態セットを取ります。このような属性の状態は、属性の値、各属性の仕様で指定されたキーワード/状態マッピングのセット、および属性の仕様で指定できる 2 つの特殊な状態を組み合わせることによって生成されます。これらの特殊な状態は、無効な値のデフォルトと欠落した値のデフォルトです。
この属性には欠損値のデフォルトはなく、無効値のデフォルトは get 状態です。
要素の method は、要素が送信ボタンであり、そのような属性がある場合は要素のformmethodの状態になります。それ以外の場合は、フォーム所有者のmethodの値(状態)です。
typeがsubmit
の時に、その要素は送信ボタンであり、typeの欠落値のデフォルトと無効な値のデフォルトは、どちらも送信ボタンの状態です。
formnovalidate属性
<input name=
"nipText" required><br> <button formnovalidate>
formnovalidateは、ブール属性です。存在する場合、フォームは送信時に検証されないことを示します。
要素が送信ボタンであり、formnovalidateがある場合、または要素のフォーム所有者のnovalidateが存在する場合は、要素の no-validate 状態は true になり、それ以外の場合は false になります。
typeがsubmit
の時に、その要素は送信ボタンであり、typeの欠落値のデフォルトと無効な値のデフォルトは、どちらも送信ボタンの状態です。
例示に於いて、typeがtext
のinputにrequiredを指定して、「入力必須」としています。また見易さの為に、inputにスタイルシートで装飾(幅)の指定をしています。
formtarget属性
<form action=
"./fmreceive.htm" target= "_top"> <button formtarget=
"nifTarget" ></form>
<iframe name=
"nifTarget"></iframe>
formtargetは、フォーム送信に有効なナビゲーション可能なターゲット名
target および formtargetコンテンツ属性が指定されている場合、その値は有効なナビゲート可能なターゲット名またはキーワードである必要があります。キーワードは ASCII 大文字と小文字を区別せずに、
- _blank: new
- _self: current
- _parent: parent
- _top: top
例示ではiframeにnameを指定して、「ターゲット名」としています。また見易さの為に、iframeにスタイルシートで装飾(幅)の指定をしています。
name属性
<button name=
"nbtName" value="ButtonName">
nameは、要素の名前を表します。
nameは、フォームの送信時やformの elements オブジェクトで使用されるフォームコントロールの名前を指定します。属性が指定されている場合、その値は空の文字列またはisindex
であってはなりません。isindex
以外では、name に空でない任意の値が許可されます。name_charset_
の ASCII 大文字と小文字を区別しない一致は特別です。valueのない Hidden コントロールの名前として使用した場合、送信時にvalueに送信文字エンコーディングで構成される値が自動的に与えられます。
nameはフォームコントロールの名前となるので、他の属性名などと重複しないように命名規則を事前に内部規則などで決めておくのが良いです。
例示では見易さの為に、inputにスタイルシートで装飾(幅)の指定をしています。
popovertarget属性
<form action=
"./fmreceive.htm"> <button type=
"button" popovertarget= "idvPopover41" >ボタン</button><input name=
"nbtSender" type= "hidden" value= "./fobutton.htm#MH3POPOVERTARGET"> </form>
<div id=
"idvPopover41" popover>Pop41</div>
popovertargetは、ポップオーバー要素を切り替え、表示、非表示にする対象とする。
指定されている場合、popovertargetの属性値は、popovertargetを持つボタンと同じツリー内のpopoverを持つ要素の ID である必要があります。
例示ではdivにidを指定して、ID としています。
popovertargetaction属性
<form action=
"./fmreceive.htm"> <button type=
"button" popovertarget= "idvPopover42" popovertargetaction= "show" >開く</button><br><button type=
"button" popovertarget= "idvPopover42" popovertargetaction= "hide" >閉じる</button><input name=
"nbtSender" type= "hidden" value= "./fobutton.htm#MH3POPOVERTARGETACTION"> </form>
<div id=
"idvPopover42" popover>Pop42</div>
popovertargetactionは、対象となるポップオーバー要素を切り替えるか、表示するか、非表示にするかを示します。
popovertargetactionは、次のキーワードと状態を持つ列挙属性です。
- toggle
- 対象となるポップオーバー要素を表示または非表示にします。
- show
- 対象となるポップオーバー要素を表示します。
- hide
- 対象のポップオーバー要素を非表示にします。
列挙属性と呼ばれる一部の属性は、有限の状態セットを取ります。このような属性の状態は、属性の値、各属性の仕様で指定されたキーワード/状態マッピングのセット、および属性の仕様で指定できる 2 つの特殊な状態を組み合わせることによって生成されます。これらの特殊な状態は、無効な値のデフォルトと欠落した値のデフォルトです。
この属性の欠落値のデフォルトと無効値のデフォルトは、どちらも切り替え状態(toggle)です。
例示ではdivにidを指定して、ID としています。
type属性
<form action=
"./fmreceive.htm"> <input name=
"nipText"><br> <button type=
"submit" >送信</button><button type=
"reset" >リセット</button><button type=
"button" >何もしない</button><input name=
"nbtSender" type= "hidden" value= "./fobutton.htm#MH3TYPE"> </form>
typeは、要素のデータ型 (および関連するコントロール) を制御します。これは、次のキーワードと状態を持つ列挙属性です。
- submit
- Submit Button フォームを送信します。
- reset
- Reset Button フォームをリセットします。
- button
- Button 何もしません。
列挙属性と呼ばれる一部の属性は、有限の状態セットを取ります。このような属性の状態は、属性の値、各属性の仕様で指定されたキーワード/状態マッピングのセット、および属性の仕様で指定できる 2 つの特殊な状態を組み合わせることによって生成されます。これらの特殊な状態は、無効な値のデフォルトと欠落した値のデフォルトです。
この属性の欠落値のデフォルトと無効値のデフォルトは、どちらも送信ボタン状態です。
value属性
<button name=
"nbtValue" value= "ButtonValue" >
valueは、フォーム送信の目的で要素の値を指定します。要素の値は、要素のvalueがある場合はその値になり、ない場合は空の文字列になります。
5.Web API
name属性を用いて
form要素
(HTMLFormElement
オブジェクト)の
プロパティとして
要素を取得する方法が
お勧めです。
button
6.レンダリング
button {
display: inline-block;
text-align: center;
box-sizing: border-box;
}
button
コードを見易くする為に要素毎に改行すると、改行コードがスペースと扱われて意図しない隙間が表れる事があります。 描画を重視するかコードの見易さを重視するか、折衷案でタグの内で改行するか、いろいろ配慮が必要です。
7.気を付ける点
ボタン
ボタンはinput