Značka HTML <textarea>


Příklad

Víceřádkový ovládací prvek pro zadávání textu (textová oblast):

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

Další příklady „Vyzkoušejte si to sami“ níže.


Definice a použití

Tag <textarea>definuje víceřádkový ovládací prvek pro zadávání textu.

Prvek <textarea>se často používá ve formuláři ke shromažďování uživatelských vstupů, jako jsou komentáře nebo recenze.

Textová oblast může obsahovat neomezený počet znaků a text se vykresluje písmem s pevnou šířkou (obvykle Courier).

Velikost textové oblasti je určena pomocí atributů <cols>a <rows>(nebo pomocí CSS).

Atribut nameje potřeba k odkazování na data formuláře po odeslání formuláře (pokud atribut vynecháte name, nebudou odeslána žádná data z textové oblasti).

Atribut idje potřeba k přiřazení textové oblasti ke štítku. 

Tip: Vždy přidejte značku <label> pro nejlepší postupy usnadnění!


Podpora prohlížeče

Element
<textarea> Yes Yes Yes Yes Yes


Atributy

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

Globální atributy

Značka <textarea>také podporuje globální atributy v HTML .


Atributy události

Značka <textarea>také podporuje atributy událostí v HTML .


Další příklady

Příklad

Zakázat výchozí možnost změny velikosti:

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

Související stránky

HTML DOM reference: Textarea Object

Kurz CSS: Stylování formulářů


Výchozí nastavení CSS

Žádný.