前端 HTML form表單標簽 textarea標簽 多行文本


 

 

<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>

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM