Why Best Practices Matter
Anyone can make a page look good with Bootstrap. A professional makes it fast, readable and easy for others to maintain.
1. Do Not Edit Bootstrap Files
Never change bootstrap.css directly. When you update Bootstrap, your changes will be lost. Write your own CSS in a separate file loaded after Bootstrap.
2. Use the Grid Correctly
- Keep the structure: container, row, columns
- Do not nest containers
- Put content inside columns, never directly in rows
- Use gutters (
g-*) instead of custom column margins
3. Do Not Overload Classes
A very long list of utility classes is hard to read. When the same group repeats, create a reusable CSS class or a component.
4. Performance
- Use the minified files (
.min.cssand.min.js) - Load the JS bundle at the end of
<body> - Remove unused components when you build with Sass
- Compress and resize images and use
loading="lazy"for images below the fold - Use WebP images and give images a width and height to avoid layout shifts
- Use a CDN or enable caching and compression on your server
5. Do Not Use Deprecated Code
| Old (Bootstrap 4) | New (Bootstrap 5) |
|---|---|
ml-3, mr-3 | ms-3, me-3 |
pl-2, pr-2 | ps-2, pe-2 |
text-left, text-right | text-start, text-end |
float-left | float-start |
btn-block | d-grid wrapper |
data-toggle | data-bs-toggle |
form-group | mb-3 |
font-weight-bold | fw-bold |
6. Keep Code Organized
- Use consistent indentation and meaningful comments
- Order classes in a logical way: layout, spacing, color, text
- Keep reusable parts, such as navbar and footer, in include files or components
Common Mistakes Checklist
- Missing the viewport meta tag
- Using fixed pixel widths that break the responsive layout
- Forgetting alt text and labels
- Loading two different Bootstrap versions on the same page
- Using too many modals, carousels and animations
Conclusion
Following these simple habits will make your projects faster, cleaner and easier to update. They are what separates a beginner's project from a professional one.

