×

HTML Forms

Forms are required when we want to collect data from the user. Html forms consists of different fields to take user inputs such as: input, text area, checkbox, password, radio button etc. Many languages are embedded with html forms to fully gain the potential use of it.
  • Html: Create forms with different fields to accept user data.
  • CSS: It enhances the style and presentation.
  • JavaScript: It provide validations for form inputs.
  • Server side languages: Like PHP. JAVA, .NET etc. different languages are used to process the data.
Syntax:
  1. <form attributes>
  2.     Form elements like: input, text area, checkbox, password, radio button
  3. </form>
Form Attributes:
  • action: It allows user data to be processed by running backend script.
  • method: It is used to upload data by 2 methods GET & POST.
  • target: It specify the target window where result is to be displayed.
  • enctype: It specifies the browser on how to encodes the data before it sends to the server.

HTML Form Controls

  • Input Controls: When user input the text then the text can be single line or multiple line thus we apply control.
  1. Single Line I/P Control: It is used when user required to enter only single line text as input such as in user name, search box etc. Syntax: <input>? tag.
  2. Multi Line I/P Control: When user details require multi-line or more than single line input. We use <textarea> tag.
<form>  
         First name: <input type = "text" name = "first_name" /><br>  
         Last name: <input type = "text" name = "last_name" /><br>  
<textarearowstextarearows = "5" cols = "50" name = "Description">  
            Enter description here...  
</textarea>  
</form>
Output:
First name: Last name: Enter description here...
  • Checkbox Control: It is used when user has to select more than one option i.e. multiple options.
Example: In case of Subject Selections, Song selection etc.
  1. <form>
  2. <input type = "checkbox" name = "maths" value = "on">Maths
  3. <input type = "checkbox" name = "physics" value = "on"> Physics
  4. </form>
Output:
Maths Physics

  • Radio Button Control: It is used when out of many option we have to select one options. It is a one to many relations. Example: In case of Gender selection etc.
<body>  
<form>  
<input type = "radio" name = "male" value = "male"> Male  
<input type = "radio" name = "female" value = "female"> Female  
</form>  
</body>
Output:
Male Female

  • Select Box Control: It is also known as drop down box where it provides a list and can select any single value from the list. Example: Selection of state, city etc.
<form>  
<select name = "dropdown">  
<option value = "State" selected>State</option>  
<option value = "Assam">Assam</option>  
<option value = "Bihar">Bihar</option>  
</select>  
</form>
Output:

  • Button Controls: Button controls are the integrated attribute of  tag with which we can create clickable buttons. Example: Submit button, Reset Button etc.
  1. <form>
  2. <input type = "submit" name = "submit" value = "Submit">
  3. <input type = "reset" name = "reset" value = "Reset">
  4. <input type = "button" name = "ok" value = "OK">
  5. </form>
Output:

  • File Upload Box: It allows user to upload file to some websites. It is also embedded with

Related Topics

HTML Paragraphs

In html, there are some elements which starts with new line and one of them is paragraph. Which is said to be a block of text. In html <p> tag...

4 minutes read.

HTML 5 Tutorial

What is HTML5? HTML5 is a programming language which stands for the acronym Hyper Text Markup Language 5. It is program that enables the appearance of web pages to be changed, as well as changes...

5 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 minutes read.

Font tag in HTML

HTML stands for Hypertext Mark-up Language and is used to create web pages and other information that can be later displayed in a web browser. It also consists of a...

4 minutes read.

HTML <body> tag

HTML means Hyper Text Markup Language, which is most preferred for making Web pages. It explains how a Web page is put together. There are many different elements in HTML,...

3 minutes read.

Html <colgroup> Tag

A HTML table's column group is specified by the "colgroup" tag. If you want to apply various properties to one or more <col> elements in an HTML table, then you...

4 minutes read.

HTML Nested Table

HTML nested table refers to a table that is created inside another table. The table is in the form of rows and columns. From left to right are called horizontal rows,...

5 minutes read.

HTML Canvas

HTML Canvas: Using JavaScript, the < canvas > tag in HTML is used for drawing graphics on web page. It can be used to draw routes, boxes, text, gradient, and...

3 minutes read.

CSS Clearfix

CSS Clearfix: A clearfix (or clear float) in CSS is for a component to clear or fix the child component, so we don’t need to insert additional markup. The clear...

4 minutes read.

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 minutes read.

How to add JavaScript to HTML

JavaScript is one of the most important languages today. It is a high-level, interpreted, lightweight programming language that makes web pages more interactive. It is a language of the web....

5 minutes read.

Responsive HTML5 and CSS3 Tutorial

Introduction to HTML5 Tutorial HTML5 is the latest and upgraded version of HTML. HTML is a hypertext markup language. Technically, it is not a programming language. It is a markup language. HTML...

17 minutes read.

What is a Container tag?

In HTML, there are different types of tags or say instructions which make the developer specify various elements in the document and make the browsers understand what to display. Tags in...

5 minutes read.

Caption Tag in HTML

Caption Tag in HTML: The < caption > tag in HTML describes the heading of a table in the HTML text. Browsers typically make the text found above the table...

4 minutes read.

How to insert image in HTML

An image (technically digital image) in HTML or even in general technical aspects is a binary representation of visual information. By visual information we mean, in the form of drawings/pictures,...

5 minutes read.

HTML <sub> tag

The sub element in HTML is used to describe one or more subscript texts. If The sub tag shows the text which is presented in a smaller font and below...

2 minutes read.

HTML Font Color

The HTML <font> tag has an attribute called color, which defines the color of the text. We use the color attribute inside the <font> tag to specify the color of...

6 minutes read.

HTML SVG

HTML SVG: SVG stands for Scalable Vector Graphics which defines the graphics for the web. It is a language for describing 2-D graphics in XML. Each drawn shape in SVG is...

1 minute read.

HTML Unordered List

In HTML, we have <ul> tag which defines the unordered list. And it is also known as bulleted list, because as we know it is not ordered list therefore it...

2 minutes read.

HTML Reset Button

The HTML reset button is used to reset all values in the form. It clears all input fields. Reset is the value of the type attribute of the button element. The...

6 minutes read.