Problem Statement
Which tag is used for multi-line text input?
Explanation
The textarea tag is used for multi-line text input in HTML forms. Unlike single-line input fields, textarea allows users to enter multiple lines of text with line breaks. This makes it perfect for comments, messages, descriptions, addresses, or any content that might span multiple lines. The textarea tag is not self-closing. You place default text between the opening and closing tags. You can control the visible size using rows and cols attributes, or use CSS width and height. The rows attribute sets the number of visible lines, and cols sets the width in characters. Users can typically resize textareas by dragging the corner. You can prevent resizing using CSS resize property. Textareas are essential for collecting longer form responses and feedback.
Code Solution
SolutionRead Only
<!-- Basic textarea -->
<form>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" cols="50"></textarea>
</form>
<!-- Textarea with placeholder and max length -->
<form>
<label for="bio">Tell us about yourself:</label>
<textarea id="bio"
name="biography"
rows="5"
maxlength="500"
placeholder="Write your bio here (max 500 characters)"
required></textarea>
</form>
<!-- Textarea with default content -->
<form>
<label for="address">Address:</label>
<textarea id="address" name="address" rows="3">
123 Main Street
City, State 12345
Country
</textarea>
</form>
<!-- Comment box -->
<form>
<label for="comment">Leave a comment:</label>
<textarea id="comment"
name="comment"
rows="6"
placeholder="Share your thoughts..."
required></textarea>
<button type="submit">Post Comment</button>
</form>