HTML Forms | Learn HTML

HTML Forms

HTML Forms are required to collect different kinds of data  or user inputs, such as contact details like name, email address, phone numbers, or messages etc.

When you see any website with contact or carrier form or any other form, those all things can be done by HTML Form also.

Forms contain special elements called controls like inputbox, checkboxes, radio-buttons, submit buttons, etc. Users generally complete a form by modifying its controls e.g. entering text, selecting items, putting date etc. and submitting the form to a web server for processing.

The <form> tag is used to create an HTML forms. Here’s a simple example of a login form:

HTML Forms | Tech-Mirror
HTML Forms | Tech-Mirror

Input Element

It is the most commonly used elements in HTML forms.

It allows you to specify various types of user input fields, depending on the type attribute. An input element can be of type text field, checkbox, password field, radio button, submit button etc. and several new input types introduced in HTML5.

The most used input types are described below.

Text Fields

Text fields are one line areas that allow the user to input text.

Single-line text input controls are created using an <input> element, whose type attribute has a value of text. Here’s an example of a single-line text input used to take username:

Password Field

Password fields are similar to text fields. The only difference is; characters in a password field are masked i.e. shown as asterisks or dots. This is to prevent others from reading the password on the screen. This is also a single-line text input controls created using an <input> element whose type attribute has a value of password.

Example of a single-line password input used to take user password is given below:

You can use many fields in a form which are given below:

  • Radio Buttons
  • File Select box
  • Checkboxes
  • Textarea
  • Select Boxes
  • Submit and Reset Buttons

Most frequently used form attributes are:

Attribute Description
name The name of the form.
action URL of the program that processes the information submitted via form.
method The HTTP method that the browser uses to submit the form. Possible values are get and post.
target A name or keyword indicating the target page where the result of the script will be displayed. The reserved keywords are _blank, _self, _parent and _top.

For More Top 10 Best HTML Editors

Leave a Reply

Your email address will not be published. Required fields are marked *