Single-page applications and <form> elements

Are there any advantages to using the <form> element instead of talking about the <div> in the context of a single-page application? The purpose of the <form> element makes sense to me if the โ€œformโ€ view is not performed using an ajax call (Iโ€™m talking about a more traditional way of submitting a form using the enter / submit button and the action attribute of the form element that describes Url to call), but otherwise I don't see its usefulness (maybe for search engines?).

+7
javascript html ajax forms single-page-application
source share
2 answers
  • Semantically, the use of <form> is clearer than <div> .
  • If you still want your form to work without JavaScript, you'd better choose <form> (since you used the word application, this may not be taken into account).
  • More importantly, it will be very painful to use a <div> if you care about accessibility .
+6
source share

I think the answer is: no, if you are not going to "submit" the form, there is no need for the <form tag. Very often, our interactive controls are in places that are not considered a โ€œformโ€ here - here you can select a menu. I think most of them work great without

Availability, I don't know anything.

-one
source share

All Articles