1.仕様
SELECT要素は、
一連のオプションの中から
選択するための
コントロールを
表します。
- select
-
選択肢の選択 (option selector)
- 種類
-
通常要素
- カテゴリ
-
- フロー
コンテンツ - フレージング
コンテンツ - インタラクティブ
コンテンツ - リストされた
要素 - ラベル付け可能な
要素 - 送信可能な
要素 - リセット可能な
要素 - 自動
大文字化 継承 要素 - フォーム
関連要素 - パルパブル
コンテンツ
- フロー
- 使用できるコンテキスト
-
フレージング
コンテンツ を受け入れる要素フレージング
コンテンツ を受け入れる要素のコンテンツとして、使用できます。フレージング
コンテンツ を受け入れる要素は、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要素 です。 - コンテンツモデル
-
(optionまたは、optgroup
要素 または、0個以上のhr) オプションでが混在(optionまたは、optgroup
要素 または、0個以上のhr)が配置できます。オプションで、を混在して配置できます。に分類される要素は、 です。
- タグの省略
-
どちらのタグも省略できません。
- コンテンツ属性
-
グローバル属性 他
- autocomplete
属性 - フォーム自動入力機能のヒント
- disabled
属性 - フォームコントロールが無効かどうか
- form
属性 - 要素をフォーム要素に関連付けます
- multiple
属性 - 複数の値を許可するかどうか
- name
属性 - フォーム送信および form.elements API で使用する要素の名前
- required
属性 - フォーム送信にコントロールが必要かどうか
- size
属性 - コントロールのサイズ
- autocomplete
- DOM インターフェイス
-
HTMLSelectElement
[Exposed=Window]
interface HTMLSelectElement : HTMLElement {
[HTMLConstructor] constructor();
[CEReactions] attribute DOMString autocomplete;
[CEReactions] attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[CEReactions] attribute boolean multiple;
[CEReactions] attribute DOMString name;
[CEReactions] attribute boolean required;
[CEReactions] attribute unsigned long size;
readonly attribute DOMString type;
[SameObject] readonly attribute HTMLOptionsCollection options;
[CEReactions] attribute unsigned long length;
getter HTMLOptionElement? item(unsigned long index);
HTMLOptionElement? namedItem(DOMString name);
[CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
[CEReactions] undefined remove(); // ChildNode overload
[CEReactions] undefined remove(long index);
[CEReactions] setter undefined (unsigned long index, HTMLOptionElement? option);
[SameObject] readonly attribute HTMLCollection selectedOptions;
attribute long selectedIndex;
attribute DOMString value;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();
undefined setCustomValidity(DOMString error);
undefined showPicker();
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
-
暗黙的="
combobox,listbox
" ARIAロール="あり" aria-* 属性="GlobalAny
"暗黙的な ARIAセマンティクスは、
role=combobox, listbox
です。
multiple属性がなく、size属性の値が1以上でない場合は role=combobox multiple属性を持つまたはsize属性の値が1より大きい場合の場合は role=listbox作成者が要素に指定してもよい ARIAロール値は、 menu, No です。
multiple属性がなく、size属性の値が1以上でない場合は role=menu multiple属性を持つまたはsize属性の値が1より大きい場合の場合は No roleグローバル aria-* 属性と、許可されたロールに適用される任意の aria-* 属性が記述できます。
作者はselect要素にaria-multiselectable属性を使うべきではありません。 - レンダリング
- インライン
レベル ボックス フォーム
コントロール select {
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: initial;
box-sizing: border-box;
}
CSS を大雑把に読むと、 インラインレベルのブロックコンテナボックス(インラインブロック)を生成します。 などになります。
- 説明
-
select
要素 は、一連のオプションの中から選択するためのコントロールを表します。<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"utf-8"> <title>select要素の例 - (Example of select element) | 離珠のHTMLでしぃ!</title>
</head>
<body>
<h1>select要素の例</h1>
<form action=
"../Html/fmreceive.htm"> <select name=
"nseSelect"> <option>ABC123</option>
<option>DEF456</option>
</select>
<button name=
"nbtSender" value= "../Html/exselect.htm">ボタン</button> <br>受信用の<br>ページへ
</form>
</body>
</html>
このサンプルへのリンクです。
(./exselect.htm) - 参照元
-
参照元
- HTML Living Standard. 4.10.7 The select 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.16 The select element (Last Updated 27 August 2024)
- HTML 5.2 W3C 勧告. 4.10.7 The select element (W3C勧告、2017年12月14日)
- HTML 5.2 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2017年12月14日)
- HTML 5.2 W3C 勧告. 10.5.14. The select element. (W3C勧告、2017年12月14日)
- HTML 5.1 W3C 勧告. 4.10.7 The select element (W3C勧告、2016年11月1日)
- HTML 5.1 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2016年11月1日)
- HTML 5.1 W3C 勧告. 10.5.14. The select element. (W3C勧告、2016年11月1日)
- HTML 5 W3C 勧告. 4.10.7 The select element (W3C勧告、2014年10月28日)
- HTML 5 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2014年10月28日)
- HTML 5 W3C 勧告. 10.5.13 The select element. (W3C勧告、2014年10月28日)
- HTML 4.01 Specification W3C 勧告. 17.6 The SELECT, OPTGROUP, and OPTION elements (W3C勧告1999年12月24日)
- HTML 3.2 Reference Specification (W3C勧告1997年1月14日)
- Hypertext Markup Language - 2.0 (November 1995)
- <select>: HTML 選択要素 - HTML: ハイパーテキストマークアップ言語 | MDN
- JSONデータ
-
JSON形式での、データのイメージです。
{
"select": {
"check": "2024-09-01",
"group": "Form",
"element": "- - ((option|optgroup|hr)*) +(%Script) -- option selector. (Normal elements.) [Flow|Phrasing|Interactive|Listed|Labelable|Submittable|Resettable|Autocapitalize|Form|Palpable] --",
"attlist": {
"%Global;": "",
"autocomplete": "(on|off) on -- Hint for form autofill feature --",
"disabled": "(disabled) #IMPLIED -- Whether the form control is disabled --",
"form": "IDREF #IMPLIED -- Associates the element with a form element --",
"multiple": "(multiple) #IMPLIED -- Whether to allow multiple values --",
"name": "CDATA #IMPLIED -- Name of the element to use for form submission and in the form.elements API --",
"required": "(required) #IMPLIED -- Whether the control is required for form submission --",
"size": "CDATA #IMPLIED -- Size of the control --",
},
"comment": "選択肢の選択 (option selector)",
"point": "一連のオプションの中から選択するためのコントロールを表します。",
"kind": "Normal",
"categories": [
"Flow",
"Phrasing",
"Interactive",
"Listed",
"Labelable",
"Submittable",
"Resettable",
"Autocapitalize",
"Formassociated",
"Palpable",
],
"used": "parent (%Phrasing)*",
"contentmodel": "select ((option|optgroup|hr)*) +(%Script)",
"tag": [
"-",
"-",
],
"attributes": {
"autocomplete": "フォーム自動入力機能のヒント",
"disabled": "フォームコントロールが無効かどうか",
"form": "要素をフォーム要素に関連付けます",
"multiple": "複数の値を許可するかどうか",
"name": "フォーム送信および form.elements API で使用する要素の名前",
"required": "フォーム送信にコントロールが必要かどうか",
"size": "コントロールのサイズ",
},
"dominterface": "HTMLSelectElement",
"rendering": "Form",
"reference": [
{
"title": "HTML Living Standard. 4.10.7 The select element.",
"href": "https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element",
"heading": "HTML Living Standard. 4.10.7 The select 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.16 The select element.",
"href": "https://html.spec.whatwg.org/multipage/rendering.html#the-select-element-2",
"heading": "HTML Living Standard. 15 Rendering 15.5.16 The select element",
"sub": "Last Updated 27 August 2024",
},
{
"title": "HTML 5.2 W3C Recommendation. 4.10.7 The select element. W3C Recommendation, 14 December 2017.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/sec-forms.html#the-select-element",
"heading": "HTML 5.2 W3C 勧告. 4.10.7 The select 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.2 W3C Recommendation. 10.5.14. The select element.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/rendering.html#the-select-element-rendering",
"heading": "HTML 5.2 W3C 勧告. 10.5.14. The select element.",
"sub": "W3C勧告、2017年12月14日",
},
{
"title": "HTML 5.1 W3C Recommendation. 4.10.7 The select element. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/sec-forms.html#the-select-element",
"heading": "HTML 5.1 W3C 勧告. 4.10.7 The select 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.1 W3C Recommendation. 10.5.14. The select element. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/rendering.html#the-select-element-rendering",
"heading": "HTML 5.1 W3C 勧告. 10.5.14. The select element.",
"sub": "W3C勧告、2016年11月1日",
},
{
"title": "HTML 5 W3C Recommendation. 4.10.7 The select element. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-select-element",
"heading": "HTML 5 W3C 勧告. 4.10.7 The select 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 5 W3C Recommendation. 10.5.13 The select element. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/rendering.html#the-select-element-0",
"heading": "HTML 5 W3C 勧告. 10.5.13 The select element.",
"sub": "W3C勧告、2014年10月28日",
},
{
"title": "HTML 4.01 Specification W3C Recommendation. 17.6 The SELECT, OPTGROUP, and OPTION elements. W3C Recommendation 24 December 1999.",
"href": "https://www.w3.org/TR/html401/interact/forms.html#h-17.6",
"heading": "HTML 4.01 Specification W3C 勧告. 17.6 The SELECT, OPTGROUP, and OPTION elements",
"sub": "W3C勧告1999年12月24日",
},
{
"title": "HTML 3.2 Reference Specification. W3C Recommendation 14-Jan-1997.",
"href": "https://www.w3.org/TR/2018/SPSD-html32-20180315/#select",
"heading": "HTML 3.2 Reference Specification",
"sub": "W3C勧告1997年1月14日",
},
{
"title": "Hypertext Markup Language - 2.0. November 1995.",
"href": "https://www.ietf.org/rfc/rfc1866.txt",
"heading": "Hypertext Markup Language - 2.0",
"sub": "November 1995",
},
{
"title": "MDN Web Docs. HTML <select>: The HTML Select element.",
"href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/select",
"heading": "<select>: HTML 選択要素 - HTML: ハイパーテキストマークアップ言語 | MDN",
},
],
"version": {
"first": "HTML2",
"latest": "HTML Living Standard",
},
}
}
注意: 簡易に描画する為に、各項目の後ろに
,
を付与しています。JSON の形式では、末尾の項目の後には,
は付けません。 - 最終確認日
-
2024-09-01
2.使用可能な箇所
フレージング
受け入れる要素に
配置できます。
select
フレージング
尚 厳密に言うと、コンテンツ
3.配置できるコンテンツ
option要素,
optgroup要素を
配置できます。
selectは、子(内容・コンテンツ・Content)として、0 以上の option要素, optgroup要素, hr要素 および script
script
4.属性
グローバル属性と、
autocomplete,
disabled, form,
multiple, name,
required, size を
設定できます。
selectは、グローバル属性とautocomplete属性, disabled属性, form属性, multiple属性, name属性, required属性, size属性を設定できます。
<form action=
"./fmreceive.htm"> <select name=
"nseSelect"> <option value="">
選択なし </option> <option>
ABC123 </option> <option>
DEF456 </option> </select>
<button name=
"nbtSender" value= "./foselect.htm#MAP4NEXT">ボタン</button> </form>
form
buttonnbtSender
で固定です。
autocomplete属性
<select name=
"nseSelect" autocomplete= "on" >
autocompleteは、ユーザーエージェントが自動入力動作を提供する方法を制御します。
disabled属性
<select name=
"nseSelect" disabled>
disabledは、コントロールを非対話型にして、その値が送信されないようにする為に使用されるブール属性です。
form属性
<form action=
"./fmreceive.htm"> <select name=
"nseSelect" form= "ifoForm441" ><option>
ABC123 </option> <option>
DEF456 </option> </select>
<button name=
"nbtSender" value= "./fotextarea.htm#MH3FORM">ボタン</button> </form>
<form id=
"ifoForm441" action= "./fmreceive.htm"> <button name=
"nbtSender" value= "./fotextarea.htm#MH3FORM">ボタン</button> </form>
formは、入力要素をそのフォーム所有者に明示的に関連付ける為に使用されます。
フォーム関連要素は、デフォルトでは、最も近い祖先form
multiple属性
<select name=
"nseSelect" multiple>
multipleは、ユーザーが複数の値を指定できるかどうかを示すブール属性です。
送信時、同一名で複数の値を送るので、受け取り側もその対応が必要です。この例示での受け取り用ページはその対応をしていませんので、ご注意下さい。
name属性
<select name=
"nseSelect" >
nameは、要素の名前を表します。
nameは、フォームの送信時やformの elements オブジェクトで使用されるフォームコントロールの名前を指定します。属性が指定されている場合、その値は空の文字列またはisindex
であってはなりません。isindex
以外では、name に空でない任意の値が許可されます。name_charset_
の ASCII 大文字と小文字を区別しない一致は特別です。valueのない Hidden コントロールの名前として使用した場合、送信時にvalueに送信文字エンコーディングで構成される値が自動的に与えられます。
nameはフォームコントロールの名前となるので、他の属性名などと重複しないように命名規則を事前に内部規則などで決めておくのが良いです。
required属性
<select name=
"nseSelect" required>
requiredは、フォーム送信にコントロールが必要かどうかを表します。requiredはブール属性です。指定されている場合、要素は必須です。
要素が必須であり、その値の IDL 属性が適用され、モード値にあり、要素が変更可能であり、要素の値が空の文字列である場合、要素は欠落している状態になります。
size属性
<select name=
"nseSelect" size= "2" >
sizeは、ユーザーに表示するオプションの数を指定します。sizeが指定されている場合、その値は 0 より大きい有効な非負の整数である必要があります。
selectの表示サイズは、非負の整数を解析するためのルールを要素のsizeの値に適用した結果です (要素にsizeがあり、解析が成功した場合)。これらのルールを属性の値に適用できない場合、またはsizeがない場合、要素の表示サイズは、要素の multiple content 属性が存在する場合は 4、存在しない場合は 1 になります。
5.Web API
name属性を用いて
form要素
(HTMLFormElement
オブジェクト)の
プロパティとして
要素を取得する方法が
お勧めです。
select
6.レンダリング
select {
display: inline-block;
text-align: initial;
box-sizing: border-box;
}
select
select のラベルの幅は、最も広い optgroup をレンダリングするために必要な幅と、要素のオプションリストで最も広いoption
コードを見易くする為に要素毎に改行すると、改行コードがスペースと扱われて意図しない隙間が表れる事があります。 描画を重視するかコードの見易さを重視するか、折衷案でタグの内で改行するか、いろいろ配慮が必要です。
7.気を付ける点
フォームの所有者
select
名前
nameを用いて名前を付ける時に、プロパティの名称と同じだとアクセスに干渉する事が考えられます。故に命名には内部規則として命名規則を事前に決めておくのが良いと思います。
尚nameがなくて名前が付いていないと、送信対象とならないみたいです。
dirnameを用いる時にも、他のフォーム送信に於けるデータの名前と重複しない様に、命名には内部規則として命名規則を事前に決めておくのが良いと思います。