單行文字框一次只能輸入一行,多行文字框則可以輸入多行,像留言、個人簡介這類欄位就靠它。要特別記住:多行文字框用的是 textarea 標籤,不是 input。
語法:
<textarea rows="行數" cols="列數">多行文字框內容</textarea>
說明:textarea 不能用 value 屬性來設定初始內容,這一點跟單行文字框不同。預設文字有兩種做法:寫在兩個標籤之間,或者乾脆不寫。
舉例:
<!DOCTYPE html> <html xmlns="https://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form name="form1" method="post" action="index.html"> 個人簡介:<br /> <textarea rows="8" cols="40">請介紹一下你自己</textarea> </form> </body> </html>
文字框其實只有三種形式:
記法很簡單——前兩種共用 input,只有多行需要另起一個 textarea 標籤。