Tag HTML <area di testo>


Esempio

Un controllo di input di testo su più righe (area di testo):

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

Altri esempi "Provalo da solo" di seguito.


Definizione e utilizzo

Il <textarea>tag definisce un controllo di input di testo su più righe.

L' <textarea>elemento viene spesso utilizzato in un modulo, per raccogliere gli input degli utenti come commenti o recensioni.

Un'area di testo può contenere un numero illimitato di caratteri e il testo viene visualizzato con un carattere a larghezza fissa (di solito Courier).

La dimensione di un'area di testo è specificata dagli attributi <cols>e (o con CSS).<rows>

L' nameattributo è necessario per fare riferimento ai dati del modulo dopo che il modulo è stato inviato (se si omette l' nameattributo, non verranno inviati dati dall'area di testo).

L' idattributo è necessario per associare l'area di testo a un'etichetta. 

Suggerimento: aggiungi sempre il tag <label> per le migliori pratiche di accessibilità!


Supporto browser

Element
<textarea> Yes Yes Yes Yes Yes


Attributi

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

Attributi globali

Il <textarea>tag supporta anche gli attributi globali in HTML .


Attributi dell'evento

Il <textarea>tag supporta anche gli attributi dell'evento in HTML .


Altri esempi

Esempio

Disattiva l'opzione di ridimensionamento predefinita:

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

Pagine correlate

Riferimento HTML DOM: Oggetto Textarea

Esercitazione CSS: stilizzazione dei moduli


Impostazioni CSS predefinite

Nessuno.