Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html form tag is sometimes absent in forms

Tags:

html

Sometimes I see a form that is wrapped in a form tag

 <form action="demo_form.asp" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
 </form>

And sometimes there is no form tag, but just a div

<div class="view">
  <input class="toggle" type="checkbox">
  <button class="destroy"></button>
</div>
<input class="edit" value="<%= title %>">

How come sometimes the form tag is present and other times its not for forms?

like image 775
User314159 Avatar asked Jan 27 '26 02:01

User314159


1 Answers

Prior to submitting information via AJAX, HTML forms were the standard in sending information to a server from a web page. They include the destination and method in the form attributes. More recently, this can be handled without assigning these attributes in form and sent via Javascript; typically using AJAX. This means the form element isn't necessary but is a good idea to include where possible to be syntactically correct HTML.

like image 99
Donnie D'Amato Avatar answered Jan 29 '26 17:01

Donnie D'Amato



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!