Creating a multi-line text area in forms is a common requirement in web development, especially when you need to collect larger amounts of text input from users, such as comments, feedback, or descriptions. The HTML `
The simplest way to create a multi-line text area is by using the `
<form action="submit.php" method="post">
<label for="comments">Comments:</label>
<textarea id="comments" name="comments" rows="4" cols="50"></textarea>
<input type="submit" value="Submit">
</form>
In this example, the `
There are several attributes you can use to customize the behavior and appearance of a `
<form action="submit.php" method="post">
<label for="feedback">Feedback:</label>
<textarea id="feedback" name="feedback" rows="6" cols="40" placeholder="Enter your feedback here..." maxlength="500" required></textarea>
<input type="submit" value="Submit">
</form>
While the default styling of a `
<style>
textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
resize: vertical; /* Allows vertical resizing only */
}
</style>
This CSS will make the text area take the full width of its container, add padding for better usability, and allow users to resize it vertically only.
In conclusion, creating a multi-line text area in forms is straightforward with the `