HTML - Form Attributes

HTML Form Attributes

In this tutorial, I am going to be showing you the different attributes associated with the <form> element.

action Attribute

The action attribute is majorly used to send user data to the server page (URL). Sometimes it can be used perform other functions using JavaScript or PHP. If the action attribute is not specified in your form, by default the action will be set to the current page.

target Attribute

The target attribute is used to set where the form response will be displayed. It takes any of these four (4) values:

  • _blank - display in a new window
  • _self - display in the same window.
  • _parent - display in the parent window.
  • _top - display in the full body of the window.
  • frame name - display in a specified iframe.

method Attribute

The method used to specify the HTTP method when submitting user data. The two types of form methods are: GET and POST

  • GET - This is the default method for sending data, but it is not secure because the data is shown at the URL.
  • GET METHOD

  • POST - This is the most secure method for sending data, as the data append inside the body of the HTTP request (i.e. the submitted form data is not shown in the URL)
  • POST METHOD

tips
TIP:

POST method is used in forms that has sensitive data like passwords.
While GET method is used in forms that has no sensitive data.


autocomplete Attribute

The autocomplete attribute is used to suggest input values based on previous inputs that has been entered before. It takes two values: ON or OFF.

novalidate Attribute

The novalidate attribute is a Boolean attribute that is used to specify that the form data should not be validated before submission.

note
NOTE:

A Boolean attribute is an attribute that stores TRUE or FALSE value of a condition. It is usually just a word. Examples of Boolean attributes: autocomplete, required, disabled, selected etc.


name Attribute

The name attribute is used the specify the name of the form. This attribute can be very useful when referencing HTML forms with JavaScript or other scripting languages.

enctype Attribute

The enctype attribute is used to set how form data should be encoded; mostly used when there is an image or file to be submitted. Also, the enctype can only be used when the method attribute is set to POST.

rel Attribute

The rel attribute is used to specify the relationship between two documents that are being link to each other. It takes the following values.

  • help - links to a help document
  • license - links to copyrighted document.
  • external - links to referenced document.
  • next - links to the next document in a selection.
  • next - links to the previous document in a selection.
  • nofollow - links to unendorsed document.
  • noreferrer - instructs browser not to send HTTP referrer header if the user follows the link.
  • search - links to a search tool for a document.

accept-charset Attribute

The accept-charset attribute is used to set the character encoding that will be used for form submission. It takes these common values:

  • UTF-8 - character encoding for Unicode.
  • ISO-8859-1 - character encoding for Latin alphabet.
ATTRIBUTES DESCRIPTION
action

Used to send user data to the server page (URL).

target

Used to set where the form response will be displayed.

method

Used to specify the HTTP method when submitting user data.

autocomplete

Used to suggest input values based on previous inputs that has been entered before.

novalidate

This is a Boolean attribute that is used to specify that the form data should not be validated before submission.

name

Used the specify the name of the form.

enctype

Used to set how form data should be encoded.

rel

Used to specify the relationship between two documents that are being link to each other.

accept-charset

Used to set the character encoding that will be used for form submission.



ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT