ข้อมูลอ้างอิงHTML

HTML โดยตัวอักษร HTML ตามหมวดหมู่ รองรับ HTML Browser แอตทริบิวต์ HTML HTML Global Attributes เหตุการณ์ HTML HTML สี HTML Canvas HTML เสียง/วิดีโอ ชุดอักขระ HTML HTML Doctypes การเข้ารหัส URL HTML รหัสภาษา HTML รหัสประเทศ HTML ข้อความ HTTP วิธี HTTP ตัวแปลง PX เป็น EM แป้นพิมพ์ลัด


HTML <textarea>แท็ก


ตัวอย่าง

ตัวควบคุมการป้อนข้อความแบบหลายบรรทัด (พื้นที่ข้อความ):

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

ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง


ความหมายและการใช้งาน

แท็ ก<textarea>กำหนดตัวควบคุมการป้อนข้อความแบบหลายบรรทัด

องค์ประกอบ<textarea>นี้มักใช้ในแบบฟอร์ม เพื่อรวบรวมอินพุตของผู้ใช้ เช่น ความคิดเห็นหรือบทวิจารณ์

พื้นที่ข้อความสามารถใส่อักขระได้ไม่จำกัด และข้อความจะแสดงเป็นแบบอักษรที่มีความกว้างคงที่ (โดยปกติคือ Courier)

ขนาดของพื้นที่ข้อความถูกระบุโดย แอตทริบิวต์ <cols>และ<rows>(หรือด้วย CSS)

จำเป็นต้อง ใช้nameแอตทริบิวต์เพื่ออ้างอิงข้อมูลในแบบฟอร์มหลังจากที่ส่งแบบฟอร์มแล้ว (หากคุณละเว้น nameแอตทริบิวต์ จะไม่มีการส่งข้อมูลจากพื้นที่ข้อความ)

จำเป็นต้อง ใช้idแอตทริบิวต์เพื่อเชื่อมโยงพื้นที่ข้อความกับป้ายกำกับ 

เคล็ดลับ:เพิ่ม แท็ก <label> เสมอ เพื่อแนวทางปฏิบัติด้านการเข้าถึงที่ดีที่สุด!


รองรับเบราว์เซอร์

Element
<textarea> Yes Yes Yes Yes Yes


คุณลักษณะ

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

คุณสมบัติสากล

แท็ ก<textarea>ยังสนับสนุน Global Attributes ในHTML


คุณสมบัติของเหตุการณ์

แท็ ก<textarea>ยังสนับสนุนแอตทริบิวต์เหตุการณ์ใน HTML


ตัวอย่างเพิ่มเติม

ตัวอย่าง

ปิดใช้งานตัวเลือกการปรับขนาดเริ่มต้น:

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

หน้าที่เกี่ยวข้อง

การอ้างอิง HTML DOM: Textarea Object

กวดวิชา CSS: แบบฟอร์มการจัดแต่งทรงผม


การตั้งค่า CSS เริ่มต้น

ไม่มี.