Form Elements or Tags
Form Elements or Tags
Label
Label is used for creating caption for input element
Label is used to identify input element (OR) data.
Syntax:
<label for=”name”>text</label>
Input
1. Submit button
Syntax:
<input type=”submit” value=”text”>
Value is used to change display text, the default display text form
input type submit is submit.
2. Reset button
Syntax:
<input type=”reset” value=”text”>
3. Button
Syntax:
<input type=”button” value=”text” onclick=function>
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Document</title>
<style>
fieldset
{
font-size: 20px;
font-weight: bold;
padding:50px;
}
label {
border: 1px solid black;
color:blue;
}
.s {
font-size: 20px;
font-family: Arial, Helvetica, sans-serif;
padding: 20px;
background-color: aqua;
color:red;
border-color: blueviolet;
border-radius: 15px;
width: 150px;
}
</style>
</head>
<body>
<form action="index.html">
<fieldset>
<legend>User Information</legend>
<label for="uname">UserName</label>
<input type="text" name="uname" id="uname"><br><br>
<label for="name">Name</label>
<input type="text" name="name" id="name"><br><br>
<input type="submit" value="Login" class="s">
<input type="reset" value="clear" class="s">
<input type="button" value="validate" class="s">
</fieldset>
</form>
</body>
</html>
<input type=”password”>
This input type used to input password values. The content input
inside password field is not visible.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Login Form</title>
<style>
</style>
</head>
<body>
<form>
<table border="1" width="80%">
<caption>Login</caption>
<tr>
<td><label for="uname">UserName</label></td>
<td><input type="text" name="uname" id="uname"
required></td>
</tr>
<tr>
<td><label for="pwd">Password</label></td>
<td><input type="password" name="pwd" id="pwd"
required></td>
</tr>
<tr>
<td><input type="submit"></td>
<td><input type="reset"></td>
</tr>
</table>
</form>
</body>
</html>
Attribute
required : if this attribute is assigned to any input field, input is
required before submitting form.