Bootstrap Form Layout Examples

Ruth Jul 09, 2026

Bootstrap, a popular open-source framework, offers a wealth of pre-built classes and components to simplify and speed up web development. When it comes to forms, Bootstrap provides a robust and responsive layout system, ensuring your forms look great and function well across various devices. Let's explore some Bootstrap form layout examples to help you create engaging and user-friendly forms.

the homepage for an employee portal with a rocket ship in the background and text that reads, apply as a employee
the homepage for an employee portal with a rocket ship in the background and text that reads, apply as a employee

Before diving into the examples, it's crucial to understand Bootstrap's grid system, which forms the foundation of its layout structure. Bootstrap uses a 12-column grid system, allowing you to create flexible and responsive layouts by dividing your content into rows and columns.

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

Basic Form Layout

Let's start with a basic form layout using Bootstrap's grid system. This example demonstrates how to create a simple form with labels, inputs, and a submit button.

Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND
Bootstrap Fieldset Legend: How To + Examples + Template | AZMIND

First, include the necessary Bootstrap and jQuery libraries in your HTML file. Then, wrap your form within a container and use the grid system to structure your form elements.

Horizontal Form

HTML Form Validation with Bootstrap
HTML Form Validation with Bootstrap

Horizontal forms align labels and form controls on the same line, making them perfect for forms with many fields. In Bootstrap, you can achieve this by adding the `.form-row` class to your form elements.

Here's an example of a horizontal form using Bootstrap's grid system:

<div class="container">
  <form>
    <div class="form-row">
      <label for="inputEmail4" class="col-form-label">Email</label>
      <input type="email" class="form-control col-7" id="inputEmail4" placeholder="email@example.com">
    </div>
    <div class="form-row">
      <label for="inputPassword4" class="col-form-label">Password</label>
      <input type="password" class="form-control col-7" id="inputPassword4" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-primary mt-4">Sign in</button>
  </form>
</div>

Vertical Form

37 Free Bootstrap Form Templates You Can Try Right Now
37 Free Bootstrap Form Templates You Can Try Right Now

Vertical forms stack labels and form controls vertically, making them ideal for forms with fewer fields or when more vertical space is available. To create a vertical form, simply remove the `.form-row` class and use Bootstrap's default form styles.

Here's an example of a vertical form:

<div class="container">
  <form>
    <div class="form-group">
      <label for="inputEmail5">Email address</label>
      <input type="email" class="form-control" id="inputEmail5" placeholder="email@example.com">
    </div>
    <div class="form-group">
      <label for="inputPassword5">Password</label>
      <input type="password" class="form-control" id="inputPassword5" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-primary mt-4">Sign in</button>
  </form>
</div>

Form Validation

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

Bootstrap provides built-in form validation styles and JavaScript plugins to help you create forms that validate client-side. This ensures a better user experience by providing instant feedback on form field errors.

To use Bootstrap's form validation, include the necessary JavaScript and CSS files, and add the appropriate validation classes to your form inputs. Bootstrap supports three validation states: success, warning, and danger.

an image of a website page with multiple screens
an image of a website page with multiple screens
Bootstrap Forms
Bootstrap Forms
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Tutorial | Bootstrap Notes | Bootstrap 5
Bootstrap Vertical Form, Horizontal Form, and Inline Form Example
Bootstrap Vertical Form, Horizontal Form, and Inline Form Example
Wizard
Wizard
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
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
Website Landing Page using HTML CSS Bootstrap 5 #3
Website Landing Page using HTML CSS Bootstrap 5 #3
Best Free Bootstrap Login Forms » CSS Author
Best Free Bootstrap Login Forms » CSS Author
Bootstrap Responsive Design Registration Form
Bootstrap Responsive Design Registration Form
Free Bootstrap 4 Login Form
Free Bootstrap 4 Login Form
Free 22+ HTML5 Signup & Registration Forms - HTML, CSS
Free 22+ HTML5 Signup & Registration Forms - HTML, CSS

Basic Validation

In this example, we'll add basic validation to our horizontal form using Bootstrap's validation classes. We'll use the `required` attribute to ensure that users fill out the form fields, and display error messages when the form is submitted with invalid data.

Here's an updated version of the horizontal form with basic validation:

<div class="container">
  <form>
    <div class="form-row">
      <label for="inputEmail4" class="col-form-label">Email</label>
      <input type="email" class="form-control col-7" id="inputEmail4" placeholder="email@example.com" required>
      <div class="invalid-feedback">Please provide a valid email address</div>
    </div>
    <div class="form-row">
      <label for="inputPassword4" class="col-form-label">Password</label>
      <input type="password" class="form-control col-7" id="inputPassword4" placeholder="Password" required>
      <div class="invalid-feedback">Please provide a valid password</div>
    </div>
    <button type="submit" class="btn btn-primary mt-4">Sign in</button>
  </form>
</div>

In this example, we've added the `required` attribute to both input fields and included `invalid-feedback` elements to display error messages when the form is submitted with invalid data.

Server-side Validation

While client-side validation provides a better user experience, it's essential to validate form data on the server-side to prevent malicious or unexpected input. In this example, we'll demonstrate how to handle server-side validation responses using Bootstrap's validation classes.

First, ensure that your server responds with appropriate HTTP status codes and JSON data when form validation fails. For example, you might return a `400 Bad Request` status code with a JSON object containing error messages for each invalid field:

{
  "errors": {
    "email": "Please provide a valid email address",
    "password": "Please provide a valid password"
  }
}

Next, use JavaScript to handle the server response and update the form's validation state accordingly. Here's an example using the jQuery library:

First, add a script tag to your HTML file and include the following JavaScript code:

<script>
  $(document).ready(function() {
    $('#myForm').submit(function(event) {
      event.preventDefault();
      var formData = $(this).serialize();
      $.ajax({
        type: 'POST',
        url: '/submit-url',
        data: formData,
        dataType: 'json',
        success: function(response) {
          if (response.success) {
            // Form submission successful
            alert('Form submitted successfully!');
          } else {
            // Form submission failed, update validation state
            $('#inputEmail4').addClass('is-invalid');
            $('#inputPassword4').addClass('is-invalid');
            $('#inputEmail4').next('.invalid-feedback').text(response.errors.email);
            $('#inputPassword4').next('.invalid-feedback').text(response.errors.password);
          }
        }
      });
    });
  });
</script>

In this example, we've added an event listener to the form's submit event. When the form is submitted, we prevent the default form submission, serialize the form data, and send an AJAX POST request to the server. If the server responds with a `success` property set to `true`, we display an alert indicating successful form submission. If the server responds with a `success` property set to `false`, we update the form's validation state using Bootstrap's validation classes and display the appropriate error messages.

Form Layout with Bootstrap 5

Bootstrap 5, the latest version of the framework, introduces several improvements and new features, including a revamped form layout system. In this section, we'll explore some of the new form layout features introduced in Bootstrap 5.

First, ensure that you're using the latest version of Bootstrap by including the following CDN link in your HTML file:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

Now, let's explore some of the new form layout features in Bootstrap 5.

Floating Labels

Bootstrap 5 introduces floating labels, which allow you to create more compact and visually appealing forms. Floating labels move above the input field as the user interacts with it, providing a better user experience and saving vertical space.

To use floating labels in Bootstrap 5, add the `.form-floating` class to your form element, and wrap your input field and label in a `.form-floating` element. Here's an example:

<div class="form-floating mb-3">
  <input type="email" class="form-control" id="floatingInput" placeholder="name@example.com">
  <label for="floatingInput">Email address</label>
</div>

In this example, we've added the `.form-floating` class to the `div` element containing the input field and label. We've also added the `placeholder` attribute to the input field, which will be replaced by the floating label when the user interacts with the input field.

Form Rows with Flexbox

Bootstrap 5 replaces the grid-based form row system with a flexbox-based system, making it easier to create complex and responsive form layouts. To create a form row with flexbox, use the `.row` class and add `.col` classes to your form elements to specify their width and order.

Here's an example of a form row with flexbox using Bootstrap 5:

<div class="row mb-3">
  <label for="inputEmail5" class="col-sm-2 col-form-label">Email</label>
  <div class="col-sm-10">
    <input type="email" class="form-control" id="inputEmail5" placeholder="email@example.com">
  </div>
</div>

In this example, we've created a form row using the `.row` class and added `.col-sm-2` and `.col-sm-10` classes to the label and input field, respectively. This creates a responsive form row that adjusts its layout based on the screen size.

As you can see, Bootstrap offers a wide range of form layout options and features to help you create engaging and user-friendly forms. By understanding and leveraging the grid system, validation classes, and new features introduced in Bootstrap 5, you can create forms that not only look great but also provide a better user experience.

To learn more about Bootstrap's form layout system and other components, be sure to check out the official Bootstrap documentation: https://getbootstrap.com/docs/5.3/forms/overview/

Happy coding!