Mastering Bootstrap 5 Forms: A Comprehensive Tutorial

Ruth Jul 09, 2026

Bootstrap, the popular open-source CSS framework, has just released its fifth iteration, Bootstrap 5. With it comes a host of new features and improvements, including a revamped forms system. In this tutorial, we'll guide you through the process of creating responsive and stylish forms using Bootstrap 5.

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Before we dive in, ensure you have the latest version of Bootstrap 5 installed. You can include it via a CDN in your HTML file or download and host the files locally. For this tutorial, we'll use the CDN method. Add the following lines in the section of your HTML file:

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Setting Up Bootstrap 5 Forms

Once Bootstrap 5 is set up, you're ready to start building forms. Bootstrap 5 uses a mobile-first approach, meaning your forms will be responsive and optimized for smaller screens by default.

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

To create a basic form, wrap your form elements within the <form> tag and add the class="needs-validation" attribute. This will enable Bootstrap's validation styles and JavaScript functionality.

Basic Form Structure

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Here's a basic example of a form structure in Bootstrap 5:

<form class="needs-validation" novalidate>
  <div class="mb-3">
    <label for="exampleInputEmail1" class="form-label">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
    <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword1" class="form-label">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1">
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

In this example, we have two input fields for email and password, along with a submit button. The mb-3 class adds margin-bottom to create space between form elements.

Form Validation

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Bootstrap 5 includes built-in form validation. To use it, add the required attribute to your input fields. For more complex validation, you can use JavaScript or a library like jQuery.

Here's an updated example with validation:

<form class="needs-validation" novalidate>
  <div class="mb-3">
    <label for="exampleInputEmail1" class="form-label">Email address</label>
    <input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" required>
    <div id="emailHelp" class="form-text">We'll never share your email with anyone else.</div>
  </div>
  <div class="mb-3">
    <label for="exampleInputPassword1" class="form-label">Password</label>
    <input type="password" class="form-control" id="exampleInputPassword1" required>
  </div>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>

Now, when a user tries to submit the form without filling out the required fields, they'll see validation messages and the form won't submit.

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5

Advanced Form Elements

Bootstrap 5 offers a variety of advanced form elements to enhance user experience. Let's explore some of them.

Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
A Beginner's Guide to the Latest Bootstrap 5 Utilities
A Beginner's Guide to the Latest Bootstrap 5 Utilities
HTML Form Validation with Bootstrap
HTML Form Validation with Bootstrap
How to Create Forms Using Bootstrap 5 and Collect Data on Static.app
How to Create Forms Using Bootstrap 5 and Collect Data on Static.app
Best Free Bootstrap Login Forms » CSS Author
Best Free Bootstrap Login Forms » CSS Author
37 Free Bootstrap Form Templates You Can Try Right Now
37 Free Bootstrap Form Templates You Can Try Right Now
How to Create a Multiple Steps Form with Bootstrap 5
How to Create a Multiple Steps Form with Bootstrap 5
How to Create a Multiple Steps Form with Bootstrap 5
How to Create a Multiple Steps Form with Bootstrap 5
How to Create Forms Using Bootstrap 5 and Collect Data on Static.app
How to Create Forms Using Bootstrap 5 and Collect Data on Static.app
Bootstrap Tutorials: The Best of Azmind | AZMIND
Bootstrap Tutorials: The Best of Azmind | AZMIND
bootstrap cheatsheet
bootstrap cheatsheet
19+ Bootstrap 5 Multi-step Form with Search Samples & Tutorial — CodeHim
19+ Bootstrap 5 Multi-step Form with Search Samples & Tutorial — CodeHim
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Bootstrap Tutorial – Introduction
Bootstrap Tutorial – Introduction

Form Select

The <select> element in Bootstrap 5 is customizable with the form-select class. Here's an example:

<select class="form-select" aria-label="default select example">
  <option selected>Open this select menu</option>
  <option value="1">One</option>
  <option value="2">Two</option>
  <option value="3">Three</option>
</select>

You can also add size="n" attribute to create a multi-select dropdown with n options visible at once.

Form Check and Radio Buttons

Bootstrap 5 introduces a new <form> element called <form-check> for checkboxes and radio buttons. Here's an example:

<div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
  <label class="form-check-label" for="flexCheckDefault">Default checkbox</label>
</div>
<div class="form-check">
  <input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1">
  <label class="form-check-label" for="flexRadioDefault1">Default radio</label>
</div>

These new elements provide better accessibility and customization options.

That's it! You now know how to create responsive and stylish forms using Bootstrap 5. Happy coding, and don't forget to explore the official Bootstrap 5 documentation for more features and examples.