Ask any question about Bootstrap here... and get an instant response.
Post this Question & Answer:
How can I align form labels and inputs in a Bootstrap horizontal form to ensure consistent spacing across all breakpoints?
Asked on Jan 17, 2026
Answer
To create a horizontal form with consistent spacing across all breakpoints in Bootstrap 5, use the grid system to align labels and inputs. This approach ensures that your form is responsive and maintains alignment on different screen sizes.
<!-- BEGIN COPY / PASTE -->
<form>
<div class="row mb-3">
<label for="inputEmail" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="row mb-3">
<label for="inputPassword" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
<div class="row mb-3">
<div class="col-sm-10 offset-sm-2">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</div>
</form>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- Use the Bootstrap grid system with `row` and `col` classes to align form elements.
- The `col-form-label` class is used to style labels within a grid layout.
- Adjust the `col-sm-*` classes to change the width of labels and inputs for different breakpoints.
- The `offset-sm-2` class is used to align the button with the input fields.
Recommended Links:
