8. Input methods in HTML

<input> Tag

  • Used to create various input elements in page.
  • controlled by attributes.
<p>Name: <input type="text" placeholder="Enter your name"></p>
<p>Password: <input type="password" placeholder="Enter your password"></p>
<input type="submit" placeholder="enter your text" >

The required Attribute:

required attribute.png

  • The required Attribute specifies that the field is required to fill before submitting a form.
  • Syntax:
<input type="text" id="username" placeholder="Text input" required>

The type Attribute:

  • The type attribute specifies the type of <input> element to display.
  • If the type attribute is not specified, the default type is "text".
  • Syntax:-
<input type="value">

There are multiple input types: