HTML - Forms Textarea

The <textarea> element is used to create a multi-line input field where users can enter and edit text.

<textarea rows="number_of_rows" cols="number_of_columns" name="field_name">Initial text</textarea>

Attributes:

  • rows: Specifies the visible number of rows in the textarea.
  • cols: Specifies the visible number of columns (characters per row) in the textarea.
  • name: Specifies the name of the textarea, used for form submission and server-side processing.

Other common attributes that can be used with the textarea element include placeholder, maxlength, readonly, required, etc.

<form>
  <label for="message">Enter your message:</label><br>
  <textarea id="message" name="message" rows="4" cols="40" placeholder="Type your message here"></textarea><br>
  <input type="submit" value="Submit">
</form>

In this example, a form is created with a textarea field. It has 4 visible rows and 40 visible columns. The placeholder attribute provides a hint to the user, and the name attribute is used to identify the field when the form is submitted.

Remember to replace number_of_rows, number_of_columns, and field_name with the appropriate values based on your requirements.

I hope this helps! Let me know if you have any further questions.