HTML forms

An HTML form is used to collect user input. The user input is most often sent to a server for processing The <form> element is a container for different types of input elements, such as text fields, checkboxes, radio buttons, submit buttons, etc.

<form>
    form elements
<form/>

Action Attribute

The action attribute defines the action to be performed when the form is submitted, which usually leads to a script that collects the information submitted and works with it. if you leave it blank, it will send it to the same file.

<form action="action.php">

Method Attribute

The method attribute is used to define the HTTP method of the form which is either GET or POST.

<form action="action.php" method="get"> 
<form action="action.php" method="post">

GET Method

The GET method is mostly used to get data, for example, to receive a post by its ID or name, or to submit a search query. The GET method will append the form data to the URL specified in the action attribute.

www.buildwithme.com/action.php?firstname-share&lastname-love

POST Method

The POST method is used when submitting data to a script. The POST method does not append the form data to the action URL but sends using the request body. To submit the data from the form correctly, a name attribute name must be specified. As an example let’s send the value of the field and set its name to Lastname:

<input type="text" name="lastname" value="Mouse">

Target Attribute

The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form. The target attribute defines the name of, or keyword for, a browsing context (e.g. tab, window, or inline frame).

<form target="_blank">
ValueDescription
_blankThe response is displayed in a new window or tab.
_selfThe response is displayed in the same frame (this is the default).
_parentThe response is displayed in the parent frame.
_topThe response is displayed in the full body of the window.


Leave a Reply

Your email address will not be published.

Recent post

Redux to a Next JS App
Redux to a Next JS App
  • July 16, 2021
How to Create Objects In JavaScript
How to Create Objects In JavaScript?
  • June 29, 2021
HTML forms
HTML Forms
  • June 23, 2021
Need a successful project?

Lets Work Together

Estimate Project
  • right image
  • Left Image