HTML 5 <textarea> 標簽
定義和用法
定義一個文本區(qū)域 (text-area) (一個多行的文本輸入?yún)^(qū)域)。用戶可在此文本區(qū)域中寫文本。在一個文本區(qū)中,您可輸入無限數(shù)量的文本。文本區(qū)中的默認字體是等寬字體 (fixed pitch)。
HTML 4.01 與 HTML 5 之間的差異
在 HTML 5 中有一些新屬性,同時不再支持 HTML 4.01 中的一些屬性。
例子
<textarea rows="3" cols="30"> 這里是文本域中的文本 ... ... ... ... </textarea>
屬性
屬性 | 值 | 描述 | 4 | 5 |
---|---|---|---|---|
autofocus |
|
在頁面加載時,使這個 textarea 獲得焦點。 | 5 | |
cols | number | 規(guī)定文本區(qū)內可見的列數(shù)。 | 4 | 5 |
disabled |
|
當此文本區(qū)首次加載時禁用此文本區(qū)。 | 4 | 5 |
form |
|
定義該 textarea 所屬的一個或多個表單。 | 5 | |
inputmode | inputmode | 定義該 textarea 所期望的輸入類型。 | 5 | |
name | name_of_textarea | 為此文本區(qū)規(guī)定的一個名稱。 | 4 | 5 |
readonly |
|
指示用戶無法修改文本區(qū)內的內容。 | 4 | 5 |
required |
|
定義為了提交該表單,該 textarea 的值是否是必需的。 | 5 | |
rows | number | 規(guī)定文本區(qū)內可見的行數(shù)。 | 4 | 5 |
標準屬性
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title
如需完整的描述,請訪問 HTML 5 中標準屬性。
事件屬性
onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload
如需完整的描述,請訪問 HTML 5 中事件屬性。
TIY 實例
- Textarea
- 如何創(chuàng)建 textarea。