Textarea And Label:

  • Welcome back to our HTML Form series! If you missed the first part, you can check it out here.
  • In this part, we'll dive into using <textarea>, <label>, and creating password fields in forms. Let's get started!

<textarea> element form:

  • The <textarea> tag in HTML is perfect when you need users to enter longer pieces of text, like comments or descriptions. It's handy for any situation where the input might be more than just a single sentence.
  • You can control the size of a <textarea> using the "rows" and "cols" attributes or through CSS. The "rows" attribute sets how many lines of text are visible, while the "cols" attribute defines the visible width of the text area.
 

Example Of Form Textarea

<form>
    Enter your address:
    <textarea rows="2" cols="20"></textarea>
</form>
Enter your address:

<Label> element form:

  • The <Label> tag in HTML is used to create a caption for a form element, like a text box or a checkbox. When users click or tap on the label, it automatically focuses on the associated input, which is especially helpful on touchscreens. This makes filling out forms easier and more intuitive.

Example Of Form Label:

<form>
    <textarea> rows="2" cols="20"></textarea>
    <label> for="firstname">First Name: </label>>label>
    <input type="text" id="firstname" name="firstname" >
    <label for="lastname">Last Name: </label>
    <input type="text" id="lastname" name="lastname" />
</form>