HTML

Form Attributes

HTML form attributes define how a form behaves and how form data is processed.

The most important <form> attributes are:

AttributeDescription
actionSpecifies where form data is sent
methodSpecifies how data is sent
targetSpecifies where the response is displayed
autocompleteControls automatic form completion
novalidateDisables 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=html

POST Method

<form action="/register" method="post">

 

The data is sent inside the HTTP request body.

Commonly:

  • GET → Searching and retrieving data
  • POST → 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>

 

Interactive Sandbox
HTML/CSS/JS