← Learning Hub
Beginner

Forms

Add form-control to inputs and form-label to labels for neat, full-width fields.

Browser default form fields look different on every device and are often small on phones. Bootstrap's form classes give every input the same clean look, full width and comfortable size for tapping. They also include styles for validation messages, checkboxes, switches and select boxes.

Example
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body class="p-3">
    <form style="max-width: 360px;">
      <div class="mb-3">
        <label for="email" class="form-label">Email</label>
        <input type="email" class="form-control" id="email" placeholder="you@example.com">
      </div>
      <div class="mb-3">
        <label for="city" class="form-label">City</label>
        <select class="form-select" id="city">
          <option>Delhi</option><option>Mumbai</option><option>Bengaluru</option>
        </select>
      </div>
      <div class="form-check mb-3">
        <input class="form-check-input" type="checkbox" id="deals">
        <label class="form-check-label" for="deals">Email me price drops</label>
      </div>
      <button type="submit" class="btn btn-primary">Save</button>
    </form>
  </body>
</html>
▶ Try it yourself

Input groups

Example
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body class="p-3">
    <div class="input-group" style="max-width: 360px;">
      <span class="input-group-text">Rs</span>
      <input type="number" class="form-control" placeholder="Max price">
      <button class="btn btn-outline-primary">Search</button>
    </div>
  </body>
</html>
▶ Try it yourself
Always connect a label to its input with for and id. Tapping the label then focuses the input, and screen readers can read it.
Key points
  • form-control styles inputs; form-label styles labels.
  • Input groups attach text like "Rs" or a button to an input.
  • Always link labels to inputs.

📝 Test yourself

1. Which class styles a text input?
2. Which class styles a drop-down list?
3. Fill in the class that groups an input with text or a button:
<div class="">