I found that SO put the search input inside a form tag, and i found some other websites do the same, such as google, they put the search input and search button inside this:
<form action="/search" method="get" name="gs" id="tsf">
I want to just know the benefits of doing so, because it seems common and I miss it.
How about you read a tutorial on HTML forms?
The data entered in the form must be send to a server. The
actionattribute tells the browser which server.Also, there are two common ways to send the data: through
POST(in theHTTPheader) and throughGET(as part of the query string, the part after the question mark in aURL). Which method must be used is specified in themethodattribute.POSTis commonly used when data should be submitted only once or should be private (e.g. registering at or logging in to a site).GETis used for data that may be send as often as necessary (because the resultingURLcontains a query string that one can e.g. bookmark). Example: Google search queries are sent usingGET, but to log in to your GMail accountPOSTis used. A more elaborate explanation can be found here.Edit: below you ask why the whole page can’t just be wrapped in one form tag. As divo correctly answers: you may have multiple forms that can be submitted to different servers. For example, you can provide two text fields on your webpage: one that allows one to search the site using Google, the other using Yahoo. With a little creativity other uses will come to mind.
Edit 2:
If that is so (I didn’t check), these two look promising: