HTML- <textarea> -Tag
Beispiel
Ein mehrzeiliges Texteingabefeld (Textbereich):
<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>
Weitere „Probieren Sie es selbst“-Beispiele weiter unten.
Definition und Verwendung
Das <textarea>
Tag definiert ein mehrzeiliges Texteingabesteuerelement.
Das <textarea>
Element wird häufig in einem Formular verwendet, um Benutzereingaben wie Kommentare oder Bewertungen zu sammeln.
Ein Textbereich kann eine unbegrenzte Anzahl von Zeichen enthalten, und der Text wird in einer Schriftart mit fester Breite (normalerweise Courier) gerendert.
Die Größe eines Textbereichs wird durch die Attribute <cols>
und <rows>
(oder mit CSS) angegeben.
Das name
Attribut wird benötigt, um auf die Formulardaten zu verweisen, nachdem das Formular gesendet wurde (wenn Sie das
name
Attribut weglassen, werden keine Daten aus dem Textbereich gesendet).
Das id
Attribut wird benötigt, um den Textbereich mit einem Label zu verknüpfen.
Tipp: Fügen Sie immer das <label> -Tag hinzu, um optimale Zugänglichkeitspraktiken zu erhalten!
Browser-Unterstützung
Element | |||||
---|---|---|---|---|---|
<textarea> | Yes | Yes | Yes | Yes | Yes |
Attribute
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 |
Globale Attribute
Das <textarea>
Tag unterstützt auch die globalen Attribute in HTML .
Ereignisattribute
Das <textarea>
Tag unterstützt auch die Ereignisattribute in HTML .
Mehr Beispiele
Beispiel
Deaktivieren Sie die Standardoption zur Größenänderung:
<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>
Verwandte Seiten
HTML-DOM-Referenz: Textarea-Objekt
CSS-Tutorial: Formulare gestalten
Standard-CSS-Einstellungen
Keiner.