Tag HTML <textarea>
Contoh
Kontrol input teks multi-baris (area teks):
<label for="w3review">Review of W3Schools:</label>
<textarea
id="w3review" name="w3review" rows="4" cols="50">
At w3schools.com you will learn how to make a website. They offer free tutorials in all web development technologies.
</textarea>
Lebih banyak contoh "Coba Sendiri" di bawah ini.
Definisi dan Penggunaan
Tag <textarea>
mendefinisikan kontrol input teks multi-baris.
Elemen <textarea>
ini sering digunakan dalam formulir, untuk mengumpulkan masukan pengguna seperti komentar atau ulasan.
Area teks dapat menampung jumlah karakter yang tidak terbatas, dan teks dirender dalam font dengan lebar tetap (biasanya Courier).
Ukuran area teks ditentukan oleh atribut <cols>
and <rows>
(atau dengan CSS).
Atribut name
diperlukan untuk mereferensikan data formulir setelah formulir dikirimkan (jika Anda menghilangkan
name
atribut, tidak ada data dari area teks yang akan dikirimkan).
Atribut id
diperlukan untuk mengaitkan area teks dengan label.
Tip: Selalu tambahkan tag <label> untuk praktik aksesibilitas terbaik!
Dukungan Peramban
Element | |||||
---|---|---|---|---|---|
<textarea> | Yes | Yes | Yes | Yes | Yes |
Atribut
Attribute | Value | Description |
---|---|---|
autofocus | autofocus | Specifies that a text area should automatically get focus when the page loads |
cols | number | Specifies the visible width of a text area |
dirname | textareaname.dir | Specifies that the text direction of the textarea will be submitted |
disabled | disabled | Specifies that a text area should be disabled |
form | form_id | Specifies which form the text area belongs to |
maxlength | number | Specifies the maximum number of characters allowed in the text area |
name | text | Specifies a name for a text area |
placeholder | text | Specifies a short hint that describes the expected value of a text area |
readonly | readonly | Specifies that a text area should be read-only |
required | required | Specifies that a text area is required/must be filled out |
rows | number | Specifies the visible number of lines in a text area |
wrap | hard soft |
Specifies how the text in a text area is to be wrapped when submitted in a form |
Atribut Global
Tag <textarea>
juga mendukung Atribut Global dalam HTML .
Atribut Acara
Tag <textarea>
juga mendukung Atribut Peristiwa dalam HTML .
Lebih Banyak Contoh
Contoh
Nonaktifkan opsi ubah ukuran default:
<html>
<head>
<style>
textarea {
resize: none;
}
</style>
</head>
<body>
<label for="w3review">Review of W3Schools:</label>
<textarea id="w3review" name="w3review" rows="4" cols="50">
At
w3schools.com you will learn how to make a website. They offer free tutorials
in all web development technologies.
</textarea>
</body>
</html>
Halaman Terkait
Referensi DOM HTML: Objek Textarea
Tutorial CSS: Menata Bentuk
Pengaturan CSS Default
Tidak ada.