Using Forms for User Input in HTML Skip to main content

Featured

Using Forms for User Input in HTML

 Program:

<!DOCTYPE html>

<html>

<body>

    <h2>Contact Us</h2>

    <form>

        <label for="name">Name:</label>

        <input type="text" id="name" name="name"><br><br>

        <label for="email">Email:</label>

        <input type="email" id="email" name="email"><br><br>

        <label for="message">Message:</label><br>

        <textarea id="message" name="message" rows="4" cols="30"></textarea><br><br>

        <input type="submit" value="Submit">

    </form>

</body>

</html>

Explanation:

  • <form> creates a form for user input.
  • <label> defines labels for form elements.
  • <input> creates input fields like text and email.
  • <textarea> creates a multiline text input field.
  • type="text" and type="email" specify the input types.
Questions and Answers:

  1. 1. What HTML tag is used to create a form for user input?

    • <form> tag is used to create a form for user input.
  2. 2. How is the 'Name' input field defined in the HTML form?

    • The 'Name' input field is defined using the <input> tag with type="text", id="name", and name="name" attributes.
  3. 3. What HTML tag is used to create a multiline text input field?

    • <textarea> tag is used to create a multiline text input field in HTML.
  4. 4. What attribute in the <textarea> tag defines the number of rows for the input field?

    • The rows attribute in the <textarea> tag defines the number of rows for the input field.
  5. 5. Which input field type is used for entering an email address?

    • type="email" is used in the <input> tag to create an input field specifically for entering an email address.

Comments

Popular Posts