THE INDIA LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

W3.CSS Input


Input Form










Top Labels

Input Form

Example

<form class="w3-container">

<label>First Name</label>
<input class="w3-input" type="text">

<label>Last Namel</label>
<input class="w3-input" type="text">

</form>
Try It Yourself »

Bottom Labels

Input Form

Example

<form class="w3-container">

<input class="w3-input" type="text">
<label>First Name</label>

<input class="w3-input" type="text">
<label>Last Name</label>

</form>
Try It Yourself »

Input Cards

Header


Example

<div class="w3-card-4">

<div class="w3-container w3-green">
  <h2>Header</h2>
</div>

<form class="w3-container">

<label class="w3-label">First Name</label>
<input class="w3-input" type="text">

<label class="w3-label">Last Name</label>
<input class="w3-input" type="text">

</form>

</div>
Try It Yourself »

Green Labels

Labels with class="w3-label" are green by default:


Example

<form class="w3-container">

<label class="w3-label">First Name</label>
<input class="w3-input" type="text">

<label class="w3-label">Last Name</label>
<input class="w3-input" type="text">

</form>
Try It Yourself »

Validating Labels

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.


Example

<form class="w3-container">

<input class="w3-input" type="text" required>
<label class="w3-label w3-validate">First Name</label>

<input class="w3-input" type="text" required>
<label class="w3-label w3-validate">Last Name</label>

<input class="w3-input" type="email" required>
<label class="w3-label w3-validate">Email</label>

</form>
Try It Yourself »

Colored Labels

Use any of the w3-text-color classes to color your labels:

Register

Example

<form class="w3-container">

<label class="w3-label w3-text-blue"><b>First Name</b></label>
<input class="w3-input w3-border" type="text">
 
<label class="w3-label w3-text-blue"><b>Last Name</b></label>
<input class="w3-input w3-border" type="text">

<button class="w3-btn w3-blue">Register</button>
 
</form>
Try It Yourself »

Bordered Input

Add the w3-border class to create bordered inputs:


Example

<input class="w3-input w3-border" type="text">
Try It Yourself »

Rounded Borders

Use any of the w3-round classes to create rounded borders:


Example

<input class="w3-input w3-border w3-round" type="text">

<input class="w3-input w3-border w3-round-large" type="text">
Try It Yourself »

Borderless Input

The w3-input class has a bottom border by default. If you want a borderless input, add the w3-border-0 class:


Example

<form class="w3-container w3-light-grey">
  <label>First Name</label>
  <input class="w3-input w3-border-0" type="text">

  <label>Last Name</label>
  <input class="w3-input w3-border-0" type="text">
</form>
Try It Yourself »

Colors

Feel free to use your favorite styles and colors:

Input Form

Register

Example

<div class="w3-container w3-teal">
  <h2>Input Form</h2>
</div>

<form class="w3-container">
  <label class="w3-label w3-text-teal"><b>First Name</b></label>
  <input class="w3-input w3-border w3-light-grey" type="text">

  <label class="w3-label w3-text-teal"><b>Last Name</b></label>
  <input class="w3-input w3-border w3-light-grey" type="text">

  <button class="w3-btn w3-blue-grey">Register</button>
</form>
Try It Yourself »

Hoverable inputs

The w3-hover-color classes adds a background color to the input field on mouse-over:

Example

<input class="w3-input w3-hover-green" type="text">
<input class="w3-input w3-border w3-hover-red" type="text">
<input class="w3-input w3-border w3-hover-blue" type="text">
Try It Yourself »

Animated Inputs

The w3-animate-input class transforms the width of an input field to 100% when it gets focus:

Example

<input class="w3-input w3-animate-input" type="text" style="width:30%">
Try It Yourself »

Checkboxes

Example

<input class="w3-check" type="checkbox" checked="checked">
<label class="w3-validate">Milk</label>

<input class="w3-check" type="checkbox">
<label class="w3-validate">Sugar</label>

<input class="w3-check" type="checkbox" disabled>
<label class="w3-validate">Lemon (Disabled)</label>
Try It Yourself »

Radio Buttons

Example

<input class="w3-radio" type="radio" name="gender" value="male" checked>
<label class="w3-validate">Male</label>

<input class="w3-radio" type="radio" name="gender" value="female">
<label class="w3-validate">Female</label>

<input class="w3-radio" type="radio" name="gender" value="" disabled>
<label class="w3-validate">Don't know (Disabled)</label>
Try It Yourself »

Select Options

Example

<select class="w3-select" name="option">
  <option value="" disabled selected>Choose your option</option>
  <option value="1">Option 1</option>
  <option value="2">Option 2</option>
  <option value="3">Option 3</option>
</select>
Try It Yourself »

Bordered Select Menu

Example

<select class="w3-select w3-border" name="option">
Try It Yourself »

Form Elements in a Grid

In this example, we use W3.CSS' Responsive Grid System to make the inputs appear on the same line (on smaller screens, they will stack horizontally with 100% width). You will learn more about this later.

Example

<div class="w3-row-padding">
  <div class="w3-third">
    <input class="w3-input w3-border" type="text" placeholder="One">
  </div>
  <div class="w3-third">
    <input class="w3-input w3-border" type="text" placeholder="Two">
  </div>
  <div class="w3-third">
    <input class="w3-input w3-border" type="text" placeholder="Three">
  </div>
</div>
Try It Yourself »

Two column layout with labels:

Example

<div class="w3-row-padding">
  <div class="w3-half">
    <label>First Name</label>
    <input class="w3-input w3-border" type="text" placeholder="Two">
  </div>
  <div class="w3-half">
    <label>Last Name</label>
    <input class="w3-input w3-border" type="text" placeholder="Three">
  </div>
</div>
Try It Yourself »