HTML Form Attributes
HTML
There are many attributes of <form>
tag which add different properties to it.
The action
attribute performs an action or task.
This action is happened as soon as the form submitted.
The form data is submitted to the server resource to process.
Most of the time action
points to the file responsible to handle the form data.
Learning with HTML Editor "Try it Now"
You can edit the HTML code and view the result using online editor.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="get" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.
The method
attribute specifies the http method.
method
is assigned by one of many http methods.
method
value can be any one of GET
, POST
GET
is used when data security is not a concern, data size is limited and webpage can be book marked.
POST
is used when data security is a concern, data size is not limited and webpage can not be book marked.
Other http methods are HEAD
, TRACE
, OPTION
, PUT
, DELETE
Learning with HTML Editor "Try it Now"
You can edit the HTML code and view the result using online editor.
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Form Example</title>
<meta charset="utf-8" />
</head>
<body>
<h2>Form Example</h2>
<form action="" method="post" class="form-example">
<div class="form-group">
<label for="name">Enter your name: </label>
<input type="text" name="name" id="name" required>
</div>
<div class="form-group">
<label for="email">Enter your email: </label>
<input type="email" name="email" id="email" required>
</div>
<div class="form-group">
<input type="submit" value="Subscribe!">
</div>
</form>
</body>
</html>
Click on the "See output" button to see how it works.