Forms & Inputs

HTML <form> Tag

The <form> tag is used to create an HTML form for user input.

Definition and Usage

The <form> tag is used to create an HTML form for user input.

Standard Syntax:<form>...</form>

Interactive ExampleRunnable

HTML <form> Example

html
Try it Yourself
Live code demonstration for the <form> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<form 
    action="/action_page.php"
    method="get">

  <label for="fname">First name:</label>
  <input type="text" id="fname" 
    name="fname"><br><br>
  <label for="lname">Last name:</label>
  
    <input type="text" id="lname" name="lname"><br><br>
  <input 
    type="submit" value="Submit">

    </form>
</div>

Attributes for <form>

9 Supported Attributes
AttributeValuesDefaultDescription
accept-charsetcharacter_setnoneSpecifies the character encodings that are to be used for the form submission
actionURLnoneSpecifies where to send the form-data when a form is submitted
autocompleteonoffnoneSpecifies whether a form should have autocomplete on or off
enctypeapplication/x-www-form-urlencoded multipart/form-data text/plainnoneSpecifies how the form-data should be encoded when submitting it to the server (only for method="post")
methoddialogget postnoneSpecifies the HTTP method to use when sending form-data
nametextnoneSpecifies the name of a form
novalidatenovalidatenoneSpecifies that the form should not be validated when submitted
relexternalhelplicensenextnofollownoopener noreferreropenerprevsearchnoneSpecifies the relationship between a linked resource and the current document
target_blank _self _parent _topnoneSpecifies where to display the response that is received after submitting the form
Global Attributes

The <form> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.

HTML Global Attributes Reference →
Event Attributes

The <form> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Forms & Inputs

View All 123Tags →