HTML <textarea> Tag


Exemplo

Um controle de entrada de texto de várias linhas (área de texto):

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

Mais exemplos de "Experimente você mesmo" abaixo.


Definição e uso

A <textarea>tag define um controle de entrada de texto de várias linhas.

O <textarea>elemento é frequentemente usado em um formulário, para coletar entradas do usuário, como comentários ou revisões.

Uma área de texto pode conter um número ilimitado de caracteres e o texto é renderizado em uma fonte de largura fixa (geralmente Courier).

O tamanho de uma área de texto é especificado pelos atributos <cols>e <rows>(ou com CSS).

O nameatributo é necessário para referenciar os dados do formulário após o envio do formulário (se você omitir o nameatributo, nenhum dado da área de texto será enviado).

O idatributo é necessário para associar a área de texto a um rótulo. 

Dica: Sempre adicione a tag <label> para melhores práticas de acessibilidade!


Suporte ao navegador

Element
<textarea> Yes Yes Yes Yes Yes


Atributos

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

Atributos Globais

A <textarea>tag também suporta os Atributos Globais em HTML .


Atributos do evento

A <textarea>tag também suporta os atributos de evento em HTML .


Mais exemplos

Exemplo

Desative a opção de redimensionamento padrão:

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

Páginas relacionadas

Referência HTML DOM: objeto Textarea

Tutorial CSS: Estilizando Formulários


Configurações padrão de CSS

Nenhum.