HTML5: How to specify one or more forms the input element belongs to?
Solution:
HTML Code:
Explanation:
- This HTML code demonstrates how to associate an input field with a specific form using the form attribute.
- The form element with the id "form1" is defined with method and action attributes to specify the form's behavior and where the form data should be submitted.
- Inside the form, there is a text input field for entering the first name and a submit button.
- The "Address" input field is placed outside the form element but is still considered part of the form because it has the form attribute set to "form1", associating it with the form with id "form1".
Live Demo :
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.