The HTML form is the interface of a web page that facilitates the user to enter data (such as name, email id, phone number etc.) that is to be sent to the server for further processing. There are various form elements that help to design a form through textbox, radio buttons, drop down menus, checkboxes, password, list, combo box etc. while writing codes.
Every form must begin with a <FORM> tag, which can be typed inside the body tag of HTML document. Syntax to create HTML form is as follows :
<HTML>
<HEAD>
<TITLE> Form Making</TITLE>
</HEAD>
<BODY>
<FORM>
Form elements
</FORM>
</BODY>
</HTML>
Form Element: In this section we will know about some form elements which are used to make a form.
Input Element:
Input Element is the main tag or element of form, used to make fields to input data from user. We can create different input fields to gather various kinds of information from a user.
Syntax to use <INPUT> tag is as follows:
<INPUT TYPE = " "Name = " "Value = " "Align = " "Size = " ">
The input tag has the following attributes :
TYPE : It specifies the type of form element such as text, radio etc.
NAME : It is the name given to form element. This attribute is used to uniquely identify the element in the form.
VALUE : It is used to specify the default value to the control element.
ALIGN : This attribute is used to align the attribute with respect to the form margins.
SIZE : This attribute specifies the horizontal size of the text box.
Adding a Text Box
A text box allows a user to enter data such as any character and number.
For example :
<HTML>
<HEAD>
<TITLE> Form </TITLE>
</HEAD>
<BODY>
<FORM>
FIRST NAME :
<INPUT Type = "TEXT" Name = "EName1" Size = "30" Value = "Enter First Name">
LAST NAME :
<INPUT Type = "TEXT" Name = "EName2" Size = "30" Value = "Enter Last Name">
Output |
Adding a Radio Button : Radio buttons are used when the user has to make selection among multiple choices or options. It is generally used for selection of gender, Yes or No, True or False, etc. For example, for accepting the gender, the programmers need to specify two radio buttons "Male" and "Female", but not both. For example:
<INPUT Type = "Radio" Name = "Gender" Value = "Female" > Female
Type = "Radio" indicates that the form element is radio button.
|
Output |
password field isn't showing the characters entered |
Combo Box : A combo box provides option to list down various options in the form of drop down list, from where a user can select desired option. <SELECT> Tag is used to start the combo box. It is a container tag. <OPTION> Tag is used to create the combo drop down list. It is an empty tag.
In Notepad++ |
In browser |
Try the above codes in Try it Editor
|
Output |
- Presentation tag in HTML
- Creating list in HTML
- Adding image in HTML
- Creating table in HTML
- Creating form in HTML
- HTML Link(External & Internal)
- Embedding Multimedia Objects in HTML
- CSS(Cascading Style Sheet)
- Introduction to JavaScript
- Attributes in HTML
- Introduction to HTML
No comments:
Post a Comment