Frequently Asked Questions
Here's a collection of common technical questions and answers that come up when working with Bootstrap.
General Questions
What is Bootstrap?
Bootstrap is an open-source front-end framework maintained by Twitter. It provides a rich set of CSS styles and JavaScript components that help developers quickly build responsive web applications.
What's the difference between Bootstrap 5 and Bootstrap 4?
The main differences:
- Bootstrap 5 dropped jQuery and uses vanilla JavaScript
- Added the XXL breakpoint
- Improved form controls
- Replaced Font Awesome with Bootstrap Icons
- No longer supports Internet Explorer
What browser support does Bootstrap need?
Just a modern browser. Bootstrap 5 requires a browser that supports ES6.
Installation Issues
CDN not loading?
- Check your internet connection
- Try a different CDN (like bootcdn or staticfile)
- Download and use locally
npm install failing?
# Clear the cache
npm cache clean --force
# Use a mirror
npm config set registry https://registry.npmmirror.com
# Try installing again
npm install bootstrap@5
Styles not working?
- Make sure the CSS file is properly linked
- Check your browser cache (force refresh with Ctrl+Shift+R)
- Look for CSS conflicts
Usage Issues
Grid system not working?
- Make sure rows are inside containers
- Make sure columns are inside rows
- Check that you're using the breakpoint classes correctly
Responsive design not working?
Make sure you've added the viewport meta tag:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Navbar not collapsing on mobile?
- Make sure you're using bootstrap.bundle.min.js (it includes Popper)
- Check the data-bs-toggle and data-bs-target attributes
Modal not popping up?
- Make sure Bootstrap JS is included
- Check the button's data-bs-toggle and data-bs-target attributes
- Verify the modal ID is correct
Dropdown not working?
- Include bootstrap.bundle.min.js
- Check that you have data-bs-toggle="dropdown" attribute
Styling Questions
How do I change theme colors?
Using Sass:
$primary: #007bff;
@import "bootstrap/scss/bootstrap";
How do I override default styles?
Use a more specific selector:
.navbar {
background-color: #f8f9fa !important;
}
How do I change the font?
$font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif;
@import "bootstrap/scss/bootstrap";
Icons not showing?
Bootstrap 5 uses Bootstrap Icons:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<i class="bi bi-alarm"></i>
Component Questions
How do I center a card?
<div class="card">
<div class="card-body">
Content
</div>
</div>
Or with flexbox:
<div class="card">
<div class="card-body d-flex justify-content-center align-items-center">
Centered content
</div>
</div>
Form validation not working?
Bootstrap 5 uses the new form validation:
<form class="row g-3 needs-validation" novalidate>
<div class="col-md-4">
<label for="validationCustom01" class="form-label">First name</label>
<input type="text" class="form-control" id="validationCustom01" required>
<div class="valid-feedback">Looks good!</div>
<div class="invalid-feedback">Please enter your name.</div>
</div>
<div class="col-12">
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</form>
<script>
(function () {
'use strict'
var forms = document.querySelectorAll('.needs-validation')
Array.prototype.slice.call(forms).forEach(function (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
}
form.classList.add('was-validated')
}, false)
})
})()
</script>
How to close modal when clicking the backdrop?
Set the backdrop attribute:
<div class="modal" data-bs-backdrop="static">
static — clicking backdrop won't close it true — clicking backdrop closes it false — backdrop is non-interactive
Performance Questions
How do I reduce file size?
- Import only what you need (using Sass)
- Use the production build
- Enable Gzip compression
How do I import styles selectively?
Use Sass to import only the components you need:
// Import required functions and variables
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
// Import only what you need
@import "bootstrap/scss/root";
@import "bootstrap/scss/reboot";
@import "bootstrap/scss/containers";
@import "bootstrap/scss/grid";
@import "bootstrap/scss/buttons";
@import "bootstrap/scss/forms";
Compatibility Questions
IE browser not supported?
Bootstrap 5 no longer supports Internet Explorer. If you need IE11 support, use Bootstrap 4.
Mobile click delay?
Bootstrap 5 uses touch-action: manipulation to eliminate the 300ms click delay on mobile.
Other Questions
Where can I get help?
- Official docs: https://getbootstrap.com/
- GitHub: https://github.com/twbs/bootstrap
How do I contribute code?
Visit the Bootstrap GitHub repository and submit a Pull Request.
How do I report a bug?
Open an issue on GitHub Issues with steps to reproduce and example code.
More Resources
- Official docs: https://getbootstrap.com/docs/5.3/
- Examples: https://getbootstrap.com/docs/5.3/examples/
