HTML form Tag Tutorial

In this section, we will learn what HTML <form> element is and how it works.

What is <form> Tag in HTML?

HTML <form> element is used to create forms in an HTML document.

In the body of this element, we can put other elements that we typically see in forms. These elements are: textboxes, radio buttons, checkboxes, dropdown boxes, etc.

Basically, the <form> element is more of a container for the items in a form!

Also, <form> element has attributes for different purposes, like one of them is to declare where the form data should be submitted (the server directory address). Or one of these attributes is used to set the HTTP method (GET, POST) that we want the form data to be sent with.

HTML <form> Tag Syntax:

<form> </form>

HTML <form> Tag Values

Within the body of HTML <form> element, we put those elements that are used to get data from users. For example, textboxes, radio buttons, checkboxes, dropdown menu, etc.

Example: form for HTML

See the Pen form for HTML by Omid Dehghan (@odchan1) on CodePen.

HTML Form Elements

There are many HTML elements that could be used in the body of <form> element, but just to name a few:

<input>

<label>

<select>

<textarea>

<button>

<fieldset>

<legend>

<datalist>

<output>

<option>

<optgroup>

Attributes of Form in HTML

Name

Description

accept-charset

This attribute is used to specify what character encoding should be used for form submission.

action

This attribute specifies where the form data should be sent after submitting.

autocomplete

This attribute specifies if the form should set autocomplete on or off

enctype

This attribute specifies how the form data should be encoded when it is being submitted to the server.

Use this attribute when using the HTTP POST method for sending data to a server.

method

This attribute specifies what HTTP method should be used when submitting form data to a server.

Possible values are POST and GET

name

With this attribute, we can set a name for the target form element.

novalidate

We use this attribute if we don’t want the form data to be validated first before being submitted to a server.

rel

This attribute specifies the relation between a linked resource and the current document.

target

With this attribute, we can specify where the response from the server should be displayed.

Note: we receive a response from a server after submitting form data first.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies