<textarea></textarea>
作用:允許用戶錄入多行數據到表單控件中
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> </head> <body> <div> <form action="http://www.baidu.com" method="get"> <div> 自我介紹: <textarea></textarea> </div> </form> </div> </body> </html>
在文本輸入內容

屬性說明:
- name:提交給服務端
- rows:設置文本區域的列數,變相設置當前元素寬度
- cols:設置文本區域的行數,變相設置當前元素高度
- disabled:禁用
設置文本域rows高度,cols寬度
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> </head> <body> <div> <form action="http://www.baidu.com" method="get"> <div> 自我介紹: <textarea cols="20" rows="5"></textarea> </div> </form> </div> </body> </html>
加上name 可以向服務端提交數據 設置默認值
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> </head> <body> <div> <form action="http://www.baidu.com" method="get"> <div> 自我介紹: <textarea cols="20" rows="5" name="text">mike</textarea> </div> </form> </div> </body> </html>
加上placehodler屬性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> </head> <body> <div> <form action="http://www.baidu.com" method="get"> <div> 自我介紹: <textarea cols="20" rows="5" name="text" placeholder="自我介紹"></textarea> </div> </form> </div> </body> </html>