Attributes on the form opening tag determine where form data goes, which HTTP method carries it, how files are encoded, and whether browser validation runs automatically before submission.
action: The destination URL that receives the submitted form data. Omitting action submits back to the current page URL.method: Sets the HTTP request method—typically get for read-only searches or post for mutations and login forms.enctype: Controls payload encoding on post requests. Default is application/x-www-form-urlencoded, while forms containing a type="file" input must use multipart/form-data.autocomplete: Accepts on or off to suggest whether browsers should autofill saved details.novalidate: Boolean attribute that disables built-in browser validation tooltips when your JavaScript framework displays custom inline error messages.target: Controls where the server response opens (_self by default, or _blank for a new tab).<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Form Attributes Demo</title>
</head>
<body>
<!-- File upload form requires POST and multipart/form-data -->
<form action="/upload-avatar" method="post" enctype="multipart/form-data" autocomplete="on">
<label for="username">Username</label>
<input id="username" name="username" type="text" required>
<label for="avatar">Profile Image</label>
<input id="avatar" name="avatar" type="file" accept="image/*">
<button type="submit">Upload Profile</button>
</form>
</body>
</html>
File uploads fail silently when enctype="multipart/form-data" is missing: the browser sends only the filename string instead of the binary file bytes. Pairing method="post" with enctype="multipart/form-data" guarantees files arrive intact on the server.
method="get": File inputs require method="post" and enctype="multipart/form-data".novalidate without custom validation: Adding novalidate turns off native checks, so make sure JavaScript or server error banners catch invalid entries.method="get": GET parameters remain visible in browser history, server access logs, and proxy caches.It splits form fields and binary file contents into separate MIME parts inside the HTTP POST body so servers can parse uploaded files.
Custom frontend apps often disable native browser popups with novalidate so they can render accessible inline validation errors under each input.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Experiment with the code from this lesson in our interactive playground.