iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

HTML Form Attributes

The <form> element accepts attributes that control how and where the data is sent.

Form attributes

AttributePurposeCommon values
actionURL to send the form to.Any path or full URL.
methodHTTP method.get, post
enctypeHow form data is encoded.application/x-www-form-urlencoded (default), multipart/form-data (for file uploads), text/plain
targetWhere the response opens._self, _blank
autocompleteWhether the browser may autofill.on, off
novalidateSkip the browser's built-in validation.(no value)
nameIdentifier — useful when many forms share a page.Any string.

GET vs POST in one sentence

  • GET: data is in the URL — fine for searches, bookmarks, and idempotent reads.
  • POST: data is in the request body — required for anything that creates, updates, or contains sensitive information.
Note: File uploads must use method="post" and enctype="multipart/form-data" — otherwise the file content never reaches the server.

Example

Example
<!DOCTYPE html>
<html>
<head>
    <title>HTML Form Attributes</title>
</head>
<body>

<h1>HTML Form Attributes</h1>
<p>This is a demo page for the "HTML Form Attributes" lesson.</p>

</body>
</html>
Try it Yourself »

Exercise

Send this form using the HTTP verb that keeps data out of the URL.

<form action="/login" ="post">…</form>

Test yourself

Q1. Browser autocomplete is hinted by…
Q2. Submit a form without leaving the page using…
Q3. novalidate attribute…

Discussion

Loading…