Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> HTML

Cách sử dụng textarea (ô nhập nhiều dòng) trong HTML

Thẻ <textarea> tạo ô nhập văn bản nhiều dòng. Kích thước qua rows và cols. Dùng trong form để nhập nội dung dài.

Bảng thuộc tính

Thuộc tínhGiá trịMô tả
autofocusautofocusTự focus khi load trang
colsnumberChiều rộng (số ký tự)
disableddisabledVô hiệu hóa
formform_idLiên kết form
maxlengthnumberSố ký tự tối đa
nametextTên control
placeholdertextGợi ý placeholder
readonlyreadonlyChỉ đọc
requiredrequiredBắt buộc nhập
rowsnumberChiều cao (số dòng)
wraphard / softChế độ gói dòng

Ví dụ

<!DOCTYPE html>
<html>
  <head>
    <title>HTML textarea Tag</title>
  </head>
  <body>
    <form action="/cgi-bin/hello_get.cgi" method="get">
      Đề xuất cải tiến cho trường học? <br>
      <textarea rows="4" cols="40" name="description">
Nhập chi tiết tại đây...
      </textarea> <br>
      <input type="submit" value="Gửi" />
    </form>
  </body>
</html>