Learn with Yasir

Share Your Feedback

Review Questions: HTML Forms and Controls


Review Questions: HTML Forms and Controls

  1. What is the purpose of the <form> element in HTML?
    Answer: It is used to create a form for user input and to send data to a server.

  2. Which attribute of the <form> element specifies the HTTP method used to send form data?
    Answer: method

  3. What is the difference between the GET and POST methods in a form?
    Answer:
    • GET: Appends form data to the URL and is visible in the address bar.
    • POST: Sends form data in the request body and is not visible in the URL.
  4. How do you create a text input field in a form?
    Answer: Use the <input type="text"> tag.

  5. Which attribute is used to make a form field mandatory?
    Answer: required

  6. How do you create a password input field in a form?
    Answer: Use the <input type="password"> tag.

  7. What is the purpose of the action attribute in a <form> element?
    Answer: It specifies the URL where the form data should be sent.

  8. How do you create a dropdown list in a form?
    Answer: Use the <select> tag with <option> tags for each item.

  9. Which attribute is used to group radio buttons together?
    Answer: name

  10. How do you create a checkbox in a form?
    Answer: Use the <input type="checkbox"> tag.

  11. What is the purpose of the placeholder attribute in an input field?
    Answer: It provides a hint or example text inside the input field.

  12. How do you create a file upload field in a form?
    Answer: Use the <input type="file"> tag.

  13. What is the purpose of the accept attribute in a file input field?
    Answer: It specifies the types of files that can be uploaded.

  14. How do you create a submit button in a form?
    Answer: Use the <input type="submit"> tag.

  15. What is the purpose of the enctype attribute in a <form> element?
    Answer: It specifies how the form data should be encoded when submitting it to the server.

  16. How do you create a date picker in a form?
    Answer: Use the <input type="date"> tag.

  17. What is the purpose of the pattern attribute in an input field?
    Answer: It specifies a regular expression that the input value must match.

  18. How do you create a range slider in a form?
    Answer: Use the <input type="range"> tag.

  19. What is the difference between the checked and selected attributes in a form?
    Answer:
    • checked: Used for checkboxes and radio buttons to pre-select an option.
    • selected: Used for dropdown lists to pre-select an option.
  20. How do you create a reset button in a form?
    Answer: Use the <input type="reset"> tag.

⭐️ HTML Contents

Learn the basics of HTML, including elements, attributes and forms controls.