Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

W3.CSS Input

W3.CSS Form Controls

The w3-input class styles text fields, email fields, textareas, and other form controls.

W3.CSS also has classes for checkboxes, radio buttons, and select menus.

Basic Input

Use the w3-input class to style an input field.

Example

<form class="w3-container">
</p>

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

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

<p>
<label>Message</label>
<textarea class="w3-input"></textarea>
</p>

</form>

Try it Yourself »


Input Borders

Add the w3-border class to create a full border around an input.

Bordered Input

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

Try it Yourself »


Labels

Labels can be placed above or below an input field.

Top Labels

Bottom Labels

Top Labels

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

Try it Yourself »

Bottom Labels

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

Try it Yourself »

Input Cards

Place a form inside a W3.CSS card.

Try it Yourself »



Checkboxes

Use the w3-check class to style checkboxes.

Example

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

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

Try it Yourself »


Radio Buttons

Use the w3-radio class to style radio buttons.

Example

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

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

Try it Yourself »


Select Menues

Use the w3-select class to style a select menu.

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 »

Add w3-border for a bordered select menu:

Example

<select class="w3-select w3-border" name="option">

Try it Yourself »


Form Elements in a Grid

Use w3-grid to place form controls next to each other.

The columns automatically stack when there is not enough space.

Example

<div class="w3-grid"
style="grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:16px">

  <input class="w3-input w3-border" type="text" placeholder="One">
  <input class="w3-input w3-border" type="text" placeholder="Two">
  <input class="w3-input w3-border" type="text" placeholder="Three">

</div>

Try it Yourself »


Grid with Labels

Example

<div class="w3-grid"
style="grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px">

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

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

</div>

Try it Yourself »

Resize the screen to see the effect.


Form Elements in a Row

In this example, we use the w3-row class (Responsive Row) to make the inputs appear on the same line.

On smaller screens, they will stack horizontally with 100% width.

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 »

What You Have Learned

  • Use w3-input for form controls
  • Use w3-border for bordered inputs
  • Use w3-check for checkboxes
  • Use w3-radio for radio buttons
  • Use w3-select for select menus
  • Use w3-grid to create responsive form layouts

More Examples

The following examples show additional ways to style form controls:


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-text-teal"><b>First Name</b></label>
  <input class="w3-input w3-border w3-light-grey" type="text">

  <label class="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 »

Colored Labels

Use text color classes to color labels.

Try it Yourself »


Icon Labels

Combine icons and form controls.

Contact Us


Try It Yourself »

Two Inputs in a Row

In this example, we use the w3-row class (Responsive Row) to make the inputs appear on the same line.

On smaller screens, they will stack horizontally with 100% width.

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 »

Hoverable Inputs

Add a hover color to an input field.

Try it Yourself »


Rounded Input

Border classes can be combined with round classes:

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 »


Animated Inputs

The w3-animate-input class animates the width of an input to 100%.

Example


Click on the inputs above to see the effect:

Try it Yourself »


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.