HTML Form

A form is defined with the <form> tag:
<form>
.
input elements
.
</form>

Input Tag and Attributes

The most used form tag is the <input> tag. The type of input is specified with the type attribute. The following types are the most commonly used input types.

Text Fields

Text fields are used when you want the user to type letters, numbers, and so on in a form.

Lets see an Example

<html>
<body>
<form action=””>
First name:
<input type=”text” name=”firstname” />
<br />
Last name:
<input type=”text” name=”lastname” />
<br>
Password:
<input type=”password” name=”password” />
</form>
</body>
</html>

form

Check Boxes

<html>
<body>
<form action=””>
I am learning<br>
Web designing <input type=”checkbox” name=”CSfield” value=”Web designing”><br>
Virus Making <input type=”checkbox” name=”CSfield” value=”Virus Making”><br>
Hacking <input type=”checkbox” name=”CSfield” value=”Hacking”>
</form>
</body>
</html>

13

Radio Buttons

<html>
<body>
<form action=””>
Male:
<input type=”radio” checked=”checked”
name=”Sex” value=”male”>
<br>
Female:
<input type=”radio”
name=”Sex” value=”female”>
</form>
</body>
</html>

14

Drop-Down List

<html>
<body>
<form action=””>
<select name=”cars”>
<option value=”volvo”>Volvo</option>
<option value=”saab”>Saab</option>
<option value=”fiat”>Fiat</option>
<option value=”audi”>Audi</option>
</select>
</form>
</body>
</html>

15

Buttons

<html>
<body>
<form name=”input” action=”html_form_submit.asp”
method=”get”>
Username:
<input type=”text” name=”user” />
<input type=”submit” value=”Submit” />
</form>
</body>
</html>

16

Leave a Reply