Common Mistakes & Best Practices
A roundup of the most common Bootstrap mistakes — from over-customizing with CSS to skipping responsive testing and accessibility.
Introduction
You now know most of Bootstrap's grid, components, utilities, and JavaScript. This lesson steps back from any single feature to cover the mistakes that consistently show up in real Bootstrap projects — and the habits that prevent them — so the sites you ship stay fast, responsive, and accessible.
- Why fighting Bootstrap with custom CSS causes long-term pain.
- How to properly test every layout across breakpoints.
- Accessibility basics: aria-labels, focus states, and color contrast.
- How to keep your final CSS/JS bundle lean.
Over-Customizing with Custom CSS
The single most common Bootstrap mistake is reaching for custom CSS — often with !important — to override spacing, colors, or alignment that a built-in utility class already handles. This produces a growing custom.css file that fights the framework, is fragile across Bootstrap upgrades, and duplicates logic that already exists.
/* Avoid: */.my-card { margin-top: 24px !important; display: flex !important; justify-content: space-between !important;}<!-- Prefer: --><div class="card d-flex justify-content-between mt-4"> <!-- ... --></div>Custom CSS is still the right tool for things Bootstrap genuinely does not offer — a unique illustration, a bespoke animation, a very specific brand pattern. The mistake is using it as the default instead of the last resort. When you do need repeated custom styling, prefer overriding Bootstrap's Sass variables (covered in the previous lesson) so the change stays consistent everywhere that variable is used.
Not Testing Responsive Breakpoints
It is easy to build and check a layout only at the browser window's current width and assume the grid classes will "just work" everywhere else. In practice, columns wrap unexpectedly, nav bars overflow, and cards touch each other because a breakpoint prefix was missed or misapplied.
<!-- Looks fine on desktop, but col-4 never adapts on mobile --><div class="row"> <div class="col-4">A</div> <div class="col-4">B</div> <div class="col-4">C</div></div>
<!-- Better: stacks on mobile, three columns from md up --><div class="row"> <div class="col-12 col-md-4">A</div> <div class="col-12 col-md-4">B</div> <div class="col-12 col-md-4">C</div></div>- xs (< 576px) — phones
- sm (≥ 576px) — large phones
- md (≥ 768px) — tablets
- lg (≥ 992px) — small laptops
- xl (≥ 1200px) — desktops
- xxl (≥ 1400px) — large desktops
Accessibility: Icon-Only Buttons
A button that only shows an icon (like a trash can or a hamburger menu) is invisible to screen readers unless it has an accessible name. This is one of the most frequent accessibility failures in Bootstrap UIs built quickly from icon components.
<!-- Inaccessible: screen reader announces "button" with no context --><button class="btn btn-outline-danger"> <i class="bi bi-trash"></i></button>
<!-- Accessible: --><button class="btn btn-outline-danger" aria-label="Delete item"> <i class="bi bi-trash" aria-hidden="true"></i></button>Accessibility: Color Contrast & Focus
Custom colors applied on top of Bootstrap (especially light text on light buttons, or muted text on a colored background) frequently fail WCAG contrast ratios. Removing Bootstrap's default focus outlines for aesthetic reasons, without replacing them, also breaks keyboard navigation for sighted keyboard users.
/* Avoid — removes focus visibility with nothing to replace it */.btn:focus { outline: none; box-shadow: none;}If you must restyle focus states, replace them with an equally visible alternative (a colored outline or box-shadow) rather than removing them outright — never ship a build with no visible focus indicator.
Bloated Bundle Size
Loading the full bootstrap.min.css and bootstrap.bundle.min.js from a CDN is fine for a prototype, but for a production site that uses only a fraction of Bootstrap's components, a Sass build with selective imports (from the previous lesson) can cut the shipped CSS considerably, improving load time.
Grid & Layout Pitfalls
Two grid mistakes come up repeatedly: nesting a .row directly inside a .col without an extra wrapping .row/.col structure correctly (the gutters compound in confusing ways when nesting is done carelessly), and forgetting that column classes need a percentage total of 12 or less per row on a given breakpoint, or they wrap unexpectedly.
<div class="row"> <div class="col-md-8"> Main content <div class="row"> <div class="col-6">Nested A</div> <div class="col-6">Nested B</div> </div> </div> <div class="col-md-4">Sidebar</div></div>JavaScript Component Pitfalls
As covered in the JavaScript components lesson, the most frequent runtime issue is loading bootstrap.min.js (without Popper) while still using dropdowns, tooltips, or popovers — those components silently fail to position correctly. Always use bootstrap.bundle.min.js unless you are managing Popper yourself.
Best Practices Checklist
- Reach for utility classes (d-flex, mt-4, text-center, etc.) before writing new custom CSS.
- Override Sass variables for repeated theme changes instead of scattering CSS overrides.
- Test every page at all six breakpoints (xs through xxl), not just your primary development width.
- Add aria-label to every icon-only interactive element.
- Never remove focus outlines without providing an equally visible replacement.
- Ship a selective Sass build in production instead of the full CDN bundle where bundle size matters.
- Use semantic HTML (real <button>, <nav>, <table>) underneath Bootstrap classes, not <div> soup.
- Run an accessibility checker (like axe or Lighthouse) on key pages before shipping.
Frequently Asked Questions
Rarely — it should be a last resort for a very specific, isolated override, not a general strategy. Reaching for it repeatedly is usually a sign you should be overriding a Sass variable or restructuring the markup instead.
Use your browser's responsive design mode (devtools device toolbar) and manually resize through each Bootstrap breakpoint width, or use a service that renders your page across common device sizes.
Adding aria-label (or visually-hidden text) to every icon-only button and link — it is quick to do, easy to miss, and directly blocks screen reader users from understanding the interface.
Key Takeaways
- Prefer Bootstrap utility classes and Sass variable overrides over ad-hoc custom CSS.
- Always test layouts across all breakpoints, not just your default development width.
- Label every icon-only button and never remove focus outlines without a replacement.
- Ship a trimmed, selectively-imported CSS/JS build in production where size matters.
Summary
Most Bootstrap problems in real projects trace back to fighting the framework instead of using its tools as designed, skipping responsive verification, or overlooking accessibility basics that take minutes to fix. With these habits in place, you're ready for the final lesson: planning and building a complete, real-world responsive landing page that ties together everything from this course.