Skip to main content
D
HTML
HTML Form Attributes

HTML Form Attributes

HTML form attributes control how forms submit data.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

HTML forms require attributes to know where and how to send data. The `action` attribute specifies the server endpoint. The `method` attribute determines if the data is sent securely or appended to the URL.

Syntax

Syntax
1<!-- form attributes -->
2<form action="/save" method="POST" target="_blank"></form>

Example

Example
1<!-- this uses form attributes -->
2<!DOCTYPE html>
3<html lang="en">
4  <head>
5    <meta charset="UTF-8">
6    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7    <title>Form Attributes</title>
8  </head>
9  <body>
10    <form action="/search" method="GET" autocomplete="off">
11      <input type="text" name="q">
12      <button type="submit">Search</button>
13    </form>
14  </body>
15</html>

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • The `action` attribute defines the URL endpoint.
  • The `method` attribute specifies POST or GET.
  • POST secures sensitive data submissions.
  • GET attaches data to the URL visibly.

Up Next

Continue your journey with the next topic.

Go to HTML Form Elements