1.仕様
TEXTAREA要素は、
生の値の複数行の
プレーンテキスト
編集コントロールを
表します。
- textarea
-
複数行のテキストフィールド (multi-line text field)
- 種類
-
エスケープ可能な生テキスト要素
テキストおよび文字参照を持つことができる要素です。
- カテゴリ
-
- フロー
コンテンツ - フレージング
コンテンツ - インタラクティブ
コンテンツ - リストされた
要素 - ラベル付け可能な
要素 - 送信可能な
要素 - リセット可能な
要素 - 自動
大文字化 継承 要素 - フォーム
関連要素 - パルパブル
コンテンツ
- フロー
- 使用できるコンテキスト
-
フレージング
コンテンツ を受け入れる要素フレージング
コンテンツ を受け入れる要素のコンテンツとして、使用できます。フレージング
コンテンツ を受け入れる要素は、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要素 です。 - コンテンツモデル
-
テキスト
テキストが配置できます。
テキストに分類される要素は、 です。
- タグの省略
-
どちらのタグも省略できません。
- コンテンツ属性
-
グローバル属性 他
- autocomplete
属性 - フォーム自動入力機能のヒント
- cols
属性 - 1 行あたりの最大文字数
- dirname
属性 - フォーム送信時に要素の方向性を送信するために使用するフォームコントロールの名前
- disabled
属性 - フォームコントロールが無効かどうか
- form
属性 - 要素をフォーム要素に関連付けます
- maxlength
属性 - 値の最大長
- minlength
属性 - 値の最小長
- name
属性 - フォーム送信および form.elements API で使用する要素の名前
- placeholder
属性 - フォームコントロール内に配置されるユーザーに見えるラベル
- readonly
属性 - ユーザーによる値の編集を許可するかどうか
- required
属性 - フォーム送信にコントロールが必要かどうか
- rows
属性 - 表示する行数
- wrap
属性 - フォーム送信のためにフォームコントロールの値をラップする方法
- autocomplete
- DOM インターフェイス
-
HTMLTextAreaElement
[Exposed=Window]
interface HTMLTextAreaElement : HTMLElement {
[HTMLConstructor] constructor();
[CEReactions] attribute DOMString autocomplete;
[CEReactions] attribute unsigned long cols;
[CEReactions] attribute DOMString dirName;
[CEReactions] attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[CEReactions] attribute long maxLength;
[CEReactions] attribute long minLength;
[CEReactions] attribute DOMString name;
[CEReactions] attribute DOMString placeholder;
[CEReactions] attribute boolean readOnly;
[CEReactions] attribute boolean required;
[CEReactions] attribute unsigned long rows;
[CEReactions] attribute DOMString wrap;
readonly attribute DOMString type;
[CEReactions] attribute DOMString defaultValue;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString value;
readonly attribute unsigned long textLength;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
boolean reportValidity();
undefined setCustomValidity(DOMString error);
readonly attribute NodeList labels;
undefined select();
attribute unsigned long selectionStart;
attribute unsigned long selectionEnd;
attribute DOMString selectionDirection;
undefined setRangeText(DOMString replacement);
undefined setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve");
undefined setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
};
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
-
暗黙的="
textbox
" ARIAロール="No
" aria-* 属性="GlobalAny
"暗黙的な ARIAセマンティクスは、
role=textbox
です。作成者は、暗黙的な ARIAセマンティクス, または HTML要素のネイティブセマンティクスを上書きしてはいけません。
グローバル aria-* 属性と、許可されたロールに適用される任意の aria-* 属性が記述できます。
- レンダリング
- インライン
レベル ボックス フォーム
コントロール textarea {
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;
white-space: pre-wrap;
}
CSS を大雑把に読むと、 インラインレベルのブロックコンテナボックス(インラインブロック)を生成します。 などになります。
- 説明
-
textarea
要素 は、要素の生の値の複数行のプレーンテキスト編集コントロールを表します。コントロールの内容は、コントロールのデフォルト値を表します。<!DOCTYPE html>
<html lang=
"ja"> <head>
<meta charset=
"utf-8"> <title>textarea要素の例 - (Example of textarea element) | 離珠のHTMLでしぃ!</title>
</head>
<body>
<h1>textarea要素の例</h1>
<form action=
"../Html/fmreceive.htm"> <textarea name=
"ntaTextarea"> abc
xyz
</textarea>
<button name=
"nbtSender" value= "../Html/extextarea.htm">ボタン</button> <br>受信用の<br>ページへ
</form>
</body>
</html>
このサンプルへのリンクです。
(./extextarea.htm) - 参照元
-
参照元
- HTML Living Standard. 4.10.11 The textarea 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.17 The textarea element (Last Updated 24 April 2024)
- HTML 5.2 W3C 勧告. 4.10.11 The textarea element (W3C勧告、2017年12月14日)
- HTML 5.2 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2017年12月14日)
- HTML 5.1 W3C 勧告. 4.10.11 The textarea element (W3C勧告、2016年11月1日)
- HTML 5.1 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2016年11月1日)
- HTML 5 W3C 勧告. 4.10.11 The textarea element (W3C勧告、2014年10月28日)
- HTML 5 W3C 勧告. 10.3.11. Form controls. (W3C勧告、2014年10月28日)
- HTML 4.01 Specification W3C 勧告. 17.7 The TEXTAREA elements (W3C勧告1999年12月24日)
- HTML 3.2 Reference Specification (W3C勧告1997年1月14日)
- Hypertext Markup Language - 2.0 (November 1995)
- <textarea>: テキストエリア要素 - HTML: ハイパーテキストマークアップ言語 | MDN
- JSONデータ
-
JSON形式での、データのイメージです。
{
"textarea": {
"check": "2024-09-01",
"group": "Form",
"element": "- - (#PCDATA) -- multi-line text field. (Escapable raw text elements.) [Flow|Phrasing|Interactive|Listed|Labelable|Submittable|Resettable|Autocapitalize|Form|Palpable] --",
"attlist": {
"%Global;": "",
"autocomplete": "(on|off) on -- Hint for form autofill feature --",
"cols": "NUMBER 20 -- Maximum number of characters per line --",
"dirname": "CDATA #IMPLIED -- Name of form control to use for sending the element's directionality in form submission --",
"disabled": "(disabled) #IMPLIED -- Whether the form control is disabled --",
"form": "IDREF #IMPLIED -- Associates the element with a form element --",
"maxlength": "NUMBER #IMPLIED -- Maximum length of value --",
"minlength": "NUMBER #IMPLIED -- Minimum length of value --",
"name": "CDATA #IMPLIED -- Name of the element to use for form submission and in the form.elements API --",
"placeholder": "CDATA #IMPLIED -- User-visible label to be placed within the form control --",
"readonly": "(readonly) #IMPLIED -- Whether to allow the value to be edited by the user --",
"required": "(required) #IMPLIED -- Whether the control is required for form submission --",
"rows": "NUMBER 2 -- Number of lines to show --",
"wrap": "(soft|hard) soft— -- How the value of the form control is to be wrapped for form submission --",
},
"comment": "複数行のテキストフィールド (multi-line text field)",
"point": "要素の生の値の複数行のプレーンテキスト編集コントロールを表します。コントロールの内容は、コントロールのデフォルト値を表します。",
"kind": "Escapable",
"categories": [
"Flow",
"Phrasing",
"Interactive",
"Listed",
"Labelable",
"Submittable",
"Resettable",
"Autocapitalize",
"Formassociated",
"Palpable",
],
"used": "parent (%Phrasing)*",
"contentmodel": "textarea (%Text)",
"tag": [
"-",
"-",
],
"attributes": {
"autocomplete": "フォーム自動入力機能のヒント",
"cols": "1 行あたりの最大文字数",
"dirname": "フォーム送信時に要素の方向性を送信するために使用するフォームコントロールの名前",
"disabled": "フォームコントロールが無効かどうか",
"form": "要素をフォーム要素に関連付けます",
"maxlength": "値の最大長",
"minlength": "値の最小長",
"name": "フォーム送信および form.elements API で使用する要素の名前",
"placeholder": "フォームコントロール内に配置されるユーザーに見えるラベル",
"readonly": "ユーザーによる値の編集を許可するかどうか",
"required": "フォーム送信にコントロールが必要かどうか",
"rows": "表示する行数",
"wrap": "フォーム送信のためにフォームコントロールの値をラップする方法",
},
"dominterface": "HTMLTextAreaElement",
"rendering": [
"Form",
"Bidirectional",
],
"reference": [
{
"title": "HTML Living Standard. 4.10.11 The textarea element.",
"href": "https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element",
"heading": "HTML Living Standard. 4.10.11 The textarea 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.17 The textarea element.",
"href": "https://html.spec.whatwg.org/multipage/rendering.html#the-textarea-element-2",
"heading": "HTML Living Standard. 15 Rendering 15.5.17 The textarea element",
"sub": "Last Updated 24 April 2024",
},
{
"title": "HTML 5.2 W3C Recommendation. 4.10.11 The textarea element. W3C Recommendation, 14 December 2017.",
"href": "https://www.w3.org/TR/2017/REC-html52-20171214/sec-forms.html#the-textarea-element",
"heading": "HTML 5.2 W3C 勧告. 4.10.11 The textarea 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.11 The textarea element. W3C Recommendation, 1 November 2016.",
"href": "https://www.w3.org/TR/2016/REC-html51-20161101/sec-forms.html#the-textarea-element",
"heading": "HTML 5.1 W3C 勧告. 4.10.11 The textarea 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.11 The textarea element. W3C Recommendation, 28 October 2014.",
"href": "https://www.w3.org/TR/2014/REC-html5-20141028/forms.html#the-textarea-element",
"heading": "HTML 5 W3C 勧告. 4.10.11 The textarea 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.7 The TEXTAREA element. W3C Recommendation 24 December 1999.",
"href": "https://www.w3.org/TR/html401/interact/forms.html#h-17.7",
"heading": "HTML 4.01 Specification W3C 勧告. 17.7 The TEXTAREA 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/#textarea",
"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 <textarea>: The Textarea element.",
"href": "https://developer.mozilla.org/ja/docs/Web/HTML/Element/textarea",
"heading": "<textarea>: テキストエリア要素 - HTML: ハイパーテキストマークアップ言語 | MDN",
},
],
"version": {
"first": "HTML2",
"latest": "HTML Living Standard",
},
}
}
注意: 簡易に描画する為に、各項目の後ろに
,
を付与しています。JSON の形式では、末尾の項目の後には,
は付けません。 - 最終確認日
-
2024-09-01
2.使用可能な箇所
フレージング
受け入れる要素に
配置できます。
textarea
フレージング
尚 厳密に言うと、コンテンツ
3.配置できるコンテンツ
テキストを
配置できます。
textareaは、子(内容・コンテンツ・Content)として、テキストを配置できます。エスケープ可能な生テキスト要素です。
4.属性
グローバル属性と、
autocomplete,
cols, dirname,
disabled, form,
maxlength,
minlength,
name,
placeholder,
readonly,
required,
rows, wrap を
設定できます。
textareaは、グローバル属性とautocomplete属性, cols属性, dirname属性, disabled属性, form属性, maxlength属性, minlength属性, name属性, placeholder属性, readonly属性, required属性, rows属性, wrap属性を設定できます。
<form action=
"./fmreceive.htm"> <textarea name=
"ntaTextarea"> abc
xyz
</textarea>
<button name=
"nbtSender" value= "./fotextarea.htm#MAP4NEXT">ボタン</button> </form>
form
buttonnbtSender
で固定です。
autocomplete属性
<textarea name=
"ntaTextarea" autocomplete= "on" >
autocompleteは、ユーザーエージェントが自動入力動作を提供する方法を制御します。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
cols属性
<textarea name=
"ntaTextarea" cols= "8" >
colsは、1 行あたりの想定最大文字数を指定します。colsが指定されている場合、その値は 0 より大きい有効な非負整数である必要があります。非負整数を解析するルールを属性値に適用した結果が 0 より大きい数値になった場合、要素の文字幅はその値になります。それ以外の場合は 20 になります。
dirname属性
<textarea name=
"ntaTextarea" dirname= "ntaDirname" >
dirnameは、要素の方向の送信を有効にし、フォーム送信中にこの値を含むコントロールの名前を指定します。このような属性を指定する場合、その値は空の文字列であってはなりません。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
disabled属性
<textarea name=
"ntaTextarea" disabled>
disabledは、コントロールを非対話型にして、その値が送信されないようにする為に使用されるブール属性です。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
form属性
<form action=
"./fmreceive.htm"> <textarea name=
"nipText" form= "ifoForm341" >abc
xyz
</textarea>
<button name=
"nbtSender" value= "./fotextarea.htm#MH3FORM">ボタン</button> </form>
<form id=
"ifoForm341" action= "./fmreceive.htm"> <button name=
"nbtSender" value= "./fotextarea.htm#MH3FORM">ボタン</button> </form>
formは、入力要素をそのフォーム所有者に明示的に関連付ける為に使用されます。
フォーム関連要素は、デフォルトでは、最も近い祖先form
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
maxlength属性
<textarea name=
"ntaTextarea" maxlength= "10" >
maxlengthは、要素の値の最大長を示します。
要素に最大許容値の長さがある場合、その要素の子は、改行が正規化された要素の子孫テキストコンテンツの値の長さが、要素の最大許容値長以下になるようにする必要があります。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
minlength属性
<textarea name=
"ntaTextarea" minlength= "6" >
minlengthは、要素の値の最小長を示します。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
name属性
<textarea name=
"ntaTextarea" >
nameは、要素の名前を表します。
nameは、フォームの送信時やformの elements オブジェクトで使用されるフォームコントロールの名前を指定します。属性が指定されている場合、その値は空の文字列またはisindex
であってはなりません。isindex
以外では、name に空でない任意の値が許可されます。name_charset_
の ASCII 大文字と小文字を区別しない一致は特別です。valueのない Hidden コントロールの名前として使用した場合、送信時にvalueに送信文字エンコーディングで構成される値が自動的に与えられます。
nameはフォームコントロールの名前となるので、他の属性名などと重複しないように命名規則を事前に内部規則などで決めておくのが良いです。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
placeholder属性
<textarea name=
"ntaTextarea" placeholder= "placeholder" >
placeholderは、コントロールに値がない場合にユーザーのデータ入力を支援するための短いヒント (単語または短いフレーズ) を表します。ヒントは、サンプル値または予想される形式の簡単な説明になります。属性を指定する場合、その値には U+000A LINE FEED (LF) または U+000D CARRIAGE RETURN (CR) 文字が含まれていてはなりません。
placeholderは、ラベルの代わりに使用しないでください。より長いヒントやその他のアドバイステキストの場合は、titleの方が適しています。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
readonly属性
<textarea name=
"ntaTextarea" readonly>
readonlyは、ユーザーがフォームコントロールを編集できるかどうかを制御するブール属性です。指定すると、要素は変更できなくなります。
textareaにreadonlyが指定されている場合、その要素は制約の検証から除外されます。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
required属性
<textarea name=
"ntaTextarea" required>
requiredは、フォーム送信にコントロールが必要かどうかを表します。requiredはブール属性です。指定されている場合、要素は必須です。
要素が必須であり、その値の IDL 属性が適用され、モード値にあり、要素が変更可能であり、要素の値が空の文字列である場合、要素は欠落している状態になります。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
rows属性
<textarea name=
"ntaTextarea" rows= "3" >
rowsは、表示する行数を指定します。rowsが指定されている場合、その値は 0 より大きい有効な非負整数である必要があります。非負整数を解析するルールを属性値に適用した結果が 0 より大きい数値になった場合、要素の文字の高さはその値になります。それ以外の場合は 2 になります。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
wrap属性
<textarea name=
"ntaTextarea" wrap= "hard" rows="3">
wrapは、フォームコントロールの値をフォーム送信時にどのようにラップするかを指定します。これは、次のキーワードと状態を持つ列挙属性です。
- soft
- Soft 送信時にテキストは折り返されません (ただし、レンダリングでラップすることはできます).
- hard
- Hard テキストは、送信時に折り返されるように、ユーザーエージェントによって改行が追加されます。
列挙属性と呼ばれる一部の属性は、有限の状態セットを取ります。このような属性の状態は、属性の値、各属性の仕様で指定されたキーワード/状態マッピングのセット、および属性の仕様で指定できる 2 つの特殊な状態を組み合わせることによって生成されます。これらの特殊な状態は、無効な値のデフォルトと欠落した値のデフォルトです。
この属性の欠落値のデフォルトと無効値のデフォルトはどちらもソフト状態です。
要素のwrapがハード状態の場合、colsを指定する必要があります。
例示では見易さの為に、textareaにスタイルシートで装飾(幅)の指定をしています。
5.Web API
name属性を用いて
form要素
(HTMLFormElement
オブジェクト)の
プロパティとして
要素を取得する方法が
お勧めです。
textarea
6.レンダリング
textarea {
display: inline-block;
white-space: pre-wrap;
text-align: initial;
box-sizing: border-box;
}
textarea
コードを見易くする為に要素毎に改行すると、改行コードがスペースと扱われて意図しない隙間が表れる事があります。 描画を重視するかコードの見易さを重視するか、折衷案でタグの内で改行するか、いろいろ配慮が必要です。
7.気を付ける点
フォームの所有者
textarea
名前
nameを用いて名前を付ける時に、プロパティの名称と同じだとアクセスに干渉する事が考えられます。故に命名には内部規則として命名規則を事前に決めておくのが良いと思います。
尚nameがなくて名前が付いていないと、送信対象とならないみたいです。
dirnameを用いる時にも、他のフォーム送信に於けるデータの名前と重複しない様に、命名には内部規則として命名規則を事前に決めておくのが良いと思います。