HTML 5 <textarea> 標(biāo)簽
定義和用法
定義一個(gè)文本區(qū)域 (text-area) (一個(gè)多行的文本輸入?yún)^(qū)域)。用戶可在此文本區(qū)域中寫文本。在一個(gè)文本區(qū)中,您可輸入無限數(shù)量的文本。文本區(qū)中的默認(rèn)字體是等寬字體 (fixed pitch)。
HTML 4.01 與 HTML 5 之間的差異
在 HTML 5 中有一些新屬性,同時(shí)不再支持 HTML 4.01 中的一些屬性。
例子
<textarea rows="3" cols="30"> 這里是文本域中的文本 ... ... ... ... </textarea>
屬性
屬性 | 值 | 描述 | 4 | 5 |
---|---|---|---|---|
autofocus |
|
在頁面加載時(shí),使這個(gè) textarea 獲得焦點(diǎn)。 | ? | 5 |
cols | number | 規(guī)定文本區(qū)內(nèi)可見的列數(shù)。 | 4 | 5 |
disabled |
|
當(dāng)此文本區(qū)首次加載時(shí)禁用此文本區(qū)。 | 4 | 5 |
form |
|
定義該 textarea 所屬的一個(gè)或多個(gè)表單。 | ? | 5 |
inputmode | inputmode | 定義該 textarea 所期望的輸入類型。 | ? | 5 |
name | name_of_textarea | 為此文本區(qū)規(guī)定的一個(gè)名稱。 | 4 | 5 |
readonly |
|
指示用戶無法修改文本區(qū)內(nèi)的內(nèi)容。 | 4 | 5 |
required |
|
定義為了提交該表單,該 textarea 的值是否是必需的。 | ? | 5 |
rows | number | 規(guī)定文本區(qū)內(nèi)可見的行數(shù)。 | 4 | 5 |
標(biāo)準(zhǔn)屬性
class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title
如需完整的描述,請?jiān)L問 HTML 5 中標(biāo)準(zhǔn)屬性。
事件屬性
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
如需完整的描述,請?jiān)L問 HTML 5 中事件屬性。
TIY 實(shí)例
- Textarea
- 如何創(chuàng)建 textarea。