The textarea tag
The textarea
tag creates a multi-line input field for use in HTML forms.
Unlike the input
tag, textarea
allows you to enter multiple lines of text, separating them with the Enter
key.
The textarea
tag must be inside the form
tag. This is not mandatory, it is necessary for sending data to the server and its subsequent processing via PHP.
By default, the user can resize the textarea
tag by dragging its bottom right corner. This behavior can be changed using the CSS property resize
.
Example . Just textrea
Let's see how the textarea
tag works:
<textarea></textarea>
:
Example . Default text
Let's try to add default text to the textarea
tag. Note that, unlike the input
tag, the textarea
tag does not have the value
attribute, and the default text is written between the opening and closing tags:
<textarea>some text</textarea>
:
Example . Stray spaces
Please note that if you place the opening and closing tags on different lines, then extra spaces will appear in this input field (how to combat this: do not place them on different lines):
<textarea>
some text
</textarea>
:
Example . Hint in textarea
Now let's add a hint placeholder
to the textarea
tag:
<textarea placeholder="i am a hint"></textarea>
: