HTML form attributes define how a form behaves and how form data is processed.
The most important <form> attributes are:
| Attribute | Description |
|---|---|
action | Specifies where form data is sent |
method | Specifies how data is sent |
target | Specifies where the response is displayed |
autocomplete | Controls automatic form completion |
novalidate | Disables browser validation |
<form
action="/submit-form"
method="post"
target="_blank"
autocomplete="on"
>
<label for="name">
Full Name:
</label>
<input
type="text"
id="name"
name="fullname"
>
<br><br>
<label for="email">
Email:
</label>
<input
type="email"
id="email"
name="email"
>
<br><br>
<button type="submit">
Submit
</button>
</form>Important Form Attributes
action
The action attribute specifies the URL where the form data should be sent.
<form action="/submit-form">For example:
<form action="process.php">When the form is submitted, the data is sent to process.php.
method
The method attribute specifies how the form data is sent.
GET Method
<form action="/search" method="get">
The data is added to the URL.
Example:
/search?keyword=htmlPOST Method
<form action="/register" method="post">
The data is sent inside the HTTP request body.
Commonly:
GET→ Searching and retrieving dataPOST→ Sending sensitive or large data
target
The target attribute specifies where the response will be displayed.
<form
action="/submit"
method="post"
target="_blank" >
Common values:
_self → Opens in the same window
_blank → Opens in a new window or tab
autocomplete
The autocomplete attribute controls whether the browser can automatically complete form values.
<form autocomplete="on">
Disable autocomplete:
<form autocomplete="off">
novalidate
The novalidate attribute disables the browser's built-in form validation.
<form novalidate>
<input
type="email"
required
>
<button type="submit">
Submit
</button>
</form>