Skip to main content
Syllabus
On this page

HTML Form Attributes (action, method, etc.)

Badar KhalilUpdated September 27, 2026 1 min read

HTML Form Attributes (action, method, etc.)

Once you understand the basic structure of a form, the next step in this HTML form attributes tutorial is learning how attributes on the <form> tag control exactly how and where data is sent when a user submits it.

The action Attribute

The action attribute specifies the URL where form data is sent upon submission. If omitted, the form submits to the current page.

Code
<form action="/submit-form">
  ...
</form>

The method Attribute

The method attribute defines the HTTP method used to send data: GET or POST.

  • GET — appends form data to the URL as query parameters. Best for search forms or non-sensitive data.
  • POST — sends data in the request body. Best for sensitive data like passwords, or large data sets.

The target Attribute

Controls where the response after submission opens: _self (default), _blank (new tab), _parent, or _top.

Required when uploading files — a very trending use-case in 2026 with the rise of drag-and-drop upload UX. Use enctype="multipart/form-data" whenever your form includes <input type="file">.

The autocomplete and novalidate Attributes

autocomplete="off" disables browser autofill suggestions, useful for sensitive one-time fields. novalidate disables the browser's built-in validation, which is useful when you want full control via custom JavaScript validation (covered later in this course).

Live Example

Try changing the method from GET to POST in the editable example below and observe how it would affect data submission.

Try it Yourself HTML
Output

Press Run to execute.

Try it Yourself HTML
Output

Press Run to execute.

Exercise: Fix the Upload FormHTML

The following form is meant to upload a file but is missing a required attribute. Add the correct enctype attribute so the file uploads properly.

Try it Yourself HTML
Output

Press Run to execute.

Show expected output
<form action='/upload' method='POST' enctype='multipart/form-data'>

This is a self-check — compare your result with the expected output above.

Was this page helpful?