W3.CSS have the different types of inputs and which have the different types of labels to give the inputs in which some are the validated input with out any scripting tags. Following are some input labeled which are listed below.
- Top and Bottom Labels
- Green labeled Forms
- Labels Validating
- Colored Labels
Top and Bottom Labels
User can design Top and Bottom labels by using the
w3-container class which is used to get the complete information about the user in the forms. The code below demonstrates to design the Top and Bottom Labels as shown.
[html]
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<div class="w3-container w3-blue">
<h2>Input Form</h2>
</div>
<form class="w3-container">
<p>
<input class="w3-input" type="text">
<label>Name</label>
</p>
<p>
<input class="w3-input" type="text">
<label>Father Name</label>
</p>
<p>
<input class="w3-input" type="text">
<label>Email</label>
</p>
<p>
<input class="w3-input" type="number">
<label>Contact Number</label>
</p>
</form>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
Green labeled Forms
In W3.CSS User can get the Green colored Labels by using the
w3-label class Green Label means The form by default gets Green color The code below demonstrates the Green Labelled Form as shown below.
[html]
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<div class="w3-container">
<h2>Input Form</h2>
</div>
<form class="w3-container">
<p>
<label class="w3-label">Name</label>
<input class="w3-input" type="text">
</p>
<p>
<label class="w3-label">Father Name</label>
<input class="w3-input" type="text">
</p>
<p>
<label class="w3-label">Contact Number</label>
<input class="w3-input" type="Number">
</p>
</form>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
Labels Validating
In W3.CSS User can also validate labels while validating the Label Red are turned into green. In order to validate these labels user need to add
w3-validate class to the
w3-label class. The code below demonstrates the Labels Validating as shown below.
[html]
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<form action="form.asp" class="w3-container">
<h2>Validating Labels</h2>
<p>Validating labels are red, and turns green when the input becomes valid. To make labels validating, add a w3-validate class to your w3-label class.</p>
<p>
<input class="w3-input" type="text" name="first" required>
<label class="w3-label w3-validate">Name</label>
</p>
<p>
<input class="w3-input" type="text" name="father" required>
<label class="w3-label w3-validate">Father Name</label>
</p>
<p>
<input class="w3-input" type="email" name="email" required>
<label class="w3-label w3-validate">Email</label>
</p>
<p>
<input class="w3-input" type="number" name="contact" required>
<label class="w3-label w3-validate">Contact Number</label>
</p>
<p>
<button class="w3-btn w3-teal">Submit</button>
</p>
</form>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.
Colored Labels
User can get any labels with colors by using the w3-
text-colors in which user can use any type of colors based on the requirement. The code below demonstrates to color the labels as shown below.
[html]
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<body>
<form class="w3-container w3-card-4" action="form.asp">
<h2 class="w3-text-purple">Input Form</h2>
<p>Use any of the w3-text-color classes to color your labels.</p>
<p>
<label class="w3-text-purple"><b>Name</b></label>
<input class="w3-input w3-border" name="first" type="text">
</p>
<p>
<label class="w3-text-purple"><b>Father Name</b></label>
<input class="w3-input w3-border" name="facther" type="text">
</p>
<p>
<label class="w3-text-purple"><b>Contact Number</b></label>
<input class="w3-input w3-border" name="number" type="number">
</p>
<p>
<button class="w3-btn w3-purple">Submit</button>
</p>
</form>
</body>
</html>
[/html]
Result
By running the above code in a preferred browser user can get the following output as shown in below image.