.form-labeland.form-controlfor text inputs..form-selectfor drop-downs..form-check,.form-check-input,.form-switchfor checkboxes and switches..input-groupadds text or buttons beside an input..form-floating: labels that float above the input.- Validation styles:
.is-valid,.is-invalidwith.invalid-feedback.
Bootstrap Forms
Styled inputs, selects, checks and validation.
✍️ 3 exercises + code challenge in this lessonKey Takeaways: Bootstrap Forms
Mastering Bootstrap Forms helps you write clean and reliable Bootstrap code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
Bootstrap Forms Code Example
Bootstrap<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="container py-3" style="max-width: 480px;">
<form>
<div class="mb-3">
<label class="form-label" for="email">Email</label>
<input type="email" class="form-control" id="email" placeholder="you@example.com">
</div>
<div class="form-floating mb-3">
<input type="password" class="form-control is-invalid" id="pw" placeholder="Password">
<label for="pw">Password</label>
<div class="invalid-feedback">Password must be 8+ characters.</div>
</div>
<div class="input-group mb-3">
<span class="input-group-text">Rs</span>
<input type="number" class="form-control" value="5000">
</div>
<select class="form-select mb-3"><option>Beginner</option><option>Advanced</option></select>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="news" checked>
<label class="form-check-label" for="news">Email me updates</label>
</div>
<button class="btn btn-primary w-100">Create account</button>
</form>
</div>
Bootstrap Forms Practice Exercises
Check what you learned in “Bootstrap Forms”.
Style a text input.
<input type="text" class="">
Which class styles a drop-down <select>?
Add an email input with the class "form-control" and a label with class "form-label".
Free sign-in required · Google login available
Stuck on something?
Ask the community in the CodesInTech forum.
Need a developer?
Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.
Explore Our Services