HTML Tutorial
<textarea>
The <textarea>
element is employed to generate a multi-line text input field, typically used for extended text input like comments, descriptions, or code snippets.
<textarea>
name
: Specifies the name of the <textarea>
.cols
: Defines the number of visible character columns in the text area.rows
: Sets the number of visible lines in the text area.placeholder
: Provides a hint about what type of text is expected to be entered.required
: Makes the input field mandatory.disabled
: Disables the <textarea>
from being edited.readonly
: Prevents the content of the <textarea>
from being changed.<textarea>
<!-- Text area for collecting user comments -->
<textarea name="comments" cols="30" rows="5"></textarea>
<!-- Disabled text area for displaying code -->
<textarea name="code" cols="50" rows="10" readonly>
Enter your code here...
</textarea>
Exploring the <textarea>
Tag: A Simple HTML Example
<!DOCTYPE html>
<html>
<head>
<title>Exploring the `<textarea>` Tag</title>
</head>
<body>
<form>
<label for="description">Description:</label>
<textarea id="description" name="description" cols="30" rows="5" placeholder="Enter a detailed description"></textarea>
<input type="submit" value="Submit">
</form>
</body>
</html>
In this example, we create a <textarea>
with a label and assign it a name, placeholder, and dimensions. When the user submits the form, the entered text can be retrieved and processed.