HTML Form Attributes

action, method, target and autocomplete.

✍️ 3 exercises + code challenge in this lesson

Attributes on the <form> element control how it is submitted:

  • action: the URL that receives the data.
  • method: GET adds data to the URL (good for searches); POST sends it in the request body (use it for passwords and anything that changes data).
  • target: where to show the response, e.g. _blank.
  • autocomplete: on or off, whether the browser suggests saved values.
  • novalidate: skips the browser's built-in validation.

Key Takeaways: HTML Form Attributes

Mastering HTML Form Attributes helps you write clean and reliable HTML code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

HTML Form Attributes Code Example

HTML
<!-- GET puts the data in the URL, like a search engine does -->
<form action="https://www.google.com/search" method="get" target="_blank">
  <label for="q">Search Google:</label>
  <input type="text" id="q" name="q" value="learn html">
  <input type="submit" value="Search">
</form>
Free sign-in required · Google login available

HTML Form Attributes Practice Exercises

Check what you learned in “HTML Form Attributes”.

/ 3 solved
Fill in the blank

Send the form data with the POST method.

<form action="/signup" ="">
✓ Correct! Not quite. Try again.
Multiple choice

Which method adds the form data to the URL?

✓ Correct! Not quite. Try again.
Code challenge

Set the form action to "/search" and the method to "get".

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services