Bootstrap interview questions and answers for frontend developers
Bootstrap interview questions check whether you can build responsive layouts with the grid without fighting it, customize the framework through Sass and CSS variables instead of overriding it, and use its JavaScript components accessibly. Expect fundamentals on containers, rows, columns and breakpoints, intermediate questions on utilities, forms, modals and theming, and senior questions on bundle size, upgrading from Bootstrap 4, and when Bootstrap is the wrong choice.
By Evin JohnPublished 7 min read
Where Bootstrap questions come up
Bootstrap is asked about in frontend, full-stack and web developer interviews, especially for teams with admin dashboards, internal tools, server-rendered apps or older codebases. The questions rarely stop at class names. Interviewers want to see that you understand the CSS the classes produce, can customize a theme cleanly, and know where Bootstrap's defaults fall short. Plain layout and cascade questions are on CSS interview questions, and the utility-first alternative on Tailwind CSS interview questions.
- Concept questionsGrid, breakpoints, containers, utilities and how components get their behavior.
- Build from a mockupA responsive card grid, a navbar that collapses, or a form with validation states.
- Customization reviewHow you would apply a brand palette and spacing without editing Bootstrap's own files.
- Senior discussionAccessibility, performance, upgrades and framework choice for a real product.
Bootstrap fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| How does the Bootstrap grid work? | Core model | Containers hold rows, rows hold columns, and each row is a flexbox line of up to 12 column units. Columns size by the number you give them or share space equally with .col. |
| What are the default breakpoints? | Responsive basics | Bootstrap 5 uses xs (no infix, below 576px), sm from 576px, md from 768px, lg from 992px, xl from 1200px and xxl from 1400px. They can be changed through Sass. |
| What does mobile-first mean for class names? | Cascade | A class like .col-md-6 applies from the md width upward. Without a larger class overriding it, it keeps applying at lg, xl and xxl. |
.container, .container-fluid or .container-md? | Layout | .container has a fixed max width per breakpoint, .container-fluid is always full width, and .container-md is full width until md, then fixed. |
| Why do rows have negative margins? | Gutters | Columns get horizontal padding for gutters; the row's negative margins cancel the outer padding so content lines up with the container edge. Gutter size is set with .g-*, .gx-* and .gy-*. |
What does .col-auto do? | Sizing | The column takes the width of its content instead of a share of the row. |
| How do you change column order on larger screens? | Ordering | .order-* and responsive versions such as .order-lg-first. Keep the source order logical, because screen readers and keyboard focus follow the HTML, not the visual order. |
| What are utility classes in Bootstrap? | Utilities | Single-purpose classes for spacing, display, flex, text, color, borders and position, such as .mt-3, .d-none .d-md-block or .text-truncate, generated by Bootstrap's utility API. |
| How do you hide an element visually but keep it for screen readers? | Accessibility | .visually-hidden (the Bootstrap 5 name for the older .sr-only). .d-none hides it from everyone. |
| Does Bootstrap 5 need jQuery? | Dependencies | No. Its JavaScript is plain JavaScript; dropdowns, popovers and tooltips rely on Popper for positioning, which the bundle file includes. |
// Mobile-first: a class applies from its breakpoint's minimum width upward,
// so the widest breakpoint that is <= the viewport wins.
const BREAKPOINTS = { xs: 0, sm: 576, md: 768, lg: 992, xl: 1200, xxl: 1400 };
function columnSpan(classes, viewport) {
let span = null;
let from = -1;
for (const cls of classes.split(/\s+/)) {
const m = cls.match(/^col(?:-(sm|md|lg|xl|xxl))?(?:-(\d+|auto))?$/);
if (!m) continue;
const min = BREAKPOINTS[m[1] ?? "xs"];
if (min <= viewport && min > from) {
from = min;
span = m[2] ?? "equal";
}
}
return span;
}
const cls = "col-12 col-md-6 col-xl-4";
for (const width of [375, 800, 1024, 1280]) {
const span = columnSpan(cls, width);
const perRow = /^\d+$/.test(span) ? 12 / Number(span) : "n/a";
console.log(`${width}px: col span ${span}, cards per row ${perRow}`);
}
// Output:
// 375px: col span 12, cards per row 1
// 800px: col span 6, cards per row 2
// 1024px: col span 6, cards per row 2
// 1280px: col span 4, cards per row 3A common trick question follows: at 1024px, does col-md-6 still apply even though there is no col-lg-* class? Yes, because nothing at lg overrides it, which is exactly what the output shows.
Components and JavaScript questions
<div class="container py-4">
<div class="row g-4">
<div class="col-12 col-md-6 col-xl-4">
<div class="card h-100">
<div class="card-body">
<h2 class="card-title h5">Usage report</h2>
<p class="card-text text-body-secondary">Monthly totals by team.</p>
<button type="button" class="btn btn-primary"
data-bs-toggle="modal" data-bs-target="#exportModal">
Export
</button>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="exportModal" tabindex="-1" aria-labelledby="exportTitle" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title fs-5" id="exportTitle">Export report</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">Choose a format.</div>
</div>
</div>
</div>- Why use `h-100` on the card? Columns in a row stretch to equal height, but the card inside does not;
h-100makes each card fill its column so the row looks even. - Why `<h2 class="h5">` instead of `<h5>`? The heading level should follow the document outline; the
.h5class only changes its size. Interviewers notice candidates who pick headings by size. - How do data attributes and the JavaScript API relate?
data-bs-toggleanddata-bs-targetwire components without code. The same components can be created in JavaScript, for examplebootstrap.Modal.getOrCreateInstance(el).show(), when you need control. - Why does a tooltip not appear even though the markup is right? Tooltips and popovers are opt-in for performance and must be initialized in JavaScript. Another cause is a disabled button, which does not fire mouse events; wrap it in an element that does.
- How do you run code after a modal opens? Listen for
shown.bs.modalon the modal element.show.bs.modalfires before the transition starts and can be cancelled. - What does the navbar's `.navbar-expand-lg` do? Below lg, the menu collapses behind a toggler button; from lg upward it shows inline. The toggler needs
aria-controlsandaria-expandedto stay accessible. - How do Bootstrap form validation styles work? Add
.was-validatedto the form to style fields by the browser's validity state, or add.is-validand.is-invalidyourself for server-side results, with.invalid-feedbacktext next to the field. - Modal or offcanvas? A modal interrupts for a focused task; offcanvas slides in a panel, often for navigation or filters on small screens. Both trap focus while open.
document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach((el) => {
bootstrap.Tooltip.getOrCreateInstance(el);
});
document.getElementById("exportModal").addEventListener("shown.bs.modal", () => {
document.getElementById("formatSelect")?.focus();
});Customization and theming questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| How do you change the primary color? | Sass basics | Override the Sass variable before importing Bootstrap, so the value flows into every component, utility and generated CSS variable. Overriding .btn-primary in your own CSS misses hover, focus, borders and other components. |
| Why does the order of Sass imports matter? | Build order | Bootstrap's variables use !default, so your values must be set before its variables file loads. Maps such as theme colors are modified after variables and before the components that use them. |
| What are Bootstrap's CSS custom properties for? | Runtime theming | Bootstrap 5 exposes values as --bs-* variables, so some things can be changed at run time or per component without recompiling Sass. |
| How do dark mode and color modes work? | Theming | Recent Bootstrap 5 releases support data-bs-theme="dark" on the root or on a single component, swapping the color variables. Check which minor version your project uses. |
| What is the utility API? | Extending utilities | A Sass map that defines which utility classes are generated. You can add a utility, add responsive versions, or remove ones you never use to shrink the CSS. |
| How do you add a brand color as a full theme color? | Maps | Merge it into the theme colors map so buttons, alerts, text and background utilities get -brand variants automatically. |
@import "bootstrap/scss/functions";
$primary: #1f6feb;
$border-radius: .5rem;
$enable-shadows: true;
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
$theme-colors: map-merge($theme-colors, ("brand": #7c3aed));
@import "bootstrap/scss/maps";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/utilities";
@import "bootstrap/scss/root";
@import "bootstrap/scss/reboot";
@import "bootstrap/scss/containers";
@import "bootstrap/scss/grid";
@import "bootstrap/scss/buttons";
@import "bootstrap/scss/card";
@import "bootstrap/scss/modal";
@import "bootstrap/scss/utilities/api";Senior and scenario questions
| Scenario | Likely issue | What a strong answer covers |
|---|---|---|
| The app ships the whole Bootstrap CSS and JS for three components. | Bundle size | Import only the Sass partials and JavaScript plugins in use, remove unused utilities through the utility API, and consider an unused-CSS step in the build, with care for classes added dynamically. |
| Overrides keep losing to Bootstrap styles. | Specificity and order | Load custom CSS after Bootstrap, match selectors rather than stacking !important, and move brand changes into Sass variables or CSS variables so there is less to override. |
| You must upgrade a large app from Bootstrap 4 to 5. | Migration | jQuery is no longer required, data attributes gained the bs prefix, left and right utilities became start and end (ms-*, me-*), .form-group and custom select classes changed, and some components were removed. Upgrade page by page with visual regression checks. |
| An accessibility audit flags modals and dropdowns. | Accessibility | Keep the ARIA attributes from the documented markup, give modals a labelled title, keep focus visible, check contrast after theme changes, and test with a keyboard and a screen reader. |
| The design team wants a unique visual style. | Framework fit | Bootstrap's defaults are recognizable. Heavy customization through Sass works, but a design system with very custom components may be easier with a utility-first approach or plain CSS. |
| A React app uses Bootstrap's JavaScript and the DOM gets out of sync. | Frameworks | Two systems are managing the same DOM. Use a React wrapper library or control component state from React and use Bootstrap only for CSS. |
Fictional example
- Interviewer
- The mockup shows one product per row on phones, two on tablets and four on desktops, with equal-height cards and a buy button aligned at the bottom.
- Candidate
- I would use a container and a row with
g-4, and give each columncol-12 col-md-6 col-lg-3, which is one, two and four per row. Each card getsh-100so cards fill the column, and I would make the card body a flex column with the button pushed down usingmt-auto, so buttons line up even when titles wrap. Product names stay as h3 under the page's h2, resized with a class if the design needs it. If the brand color differs from the default primary, I would set it in Sass rather than overriding button styles. Then I would check it at the real breakpoints and with keyboard focus on each button.
Bootstrap practice plan
- Day 1: recreate a three-breakpoint layout from a screenshot using only grid and spacing classes, and explain what each class compiles to.
- Day 2: build a navbar, a modal form with validation states and a tooltip, initialized from JavaScript, and test them with the keyboard.
- Day 3: set up a Sass build that changes the primary color, radius and fonts, adds one theme color, and drops unused components.
- Day 4: migrate a small Bootstrap 4 page to 5 using the official migration notes, and list every class you changed.
- Day 5: rehearse the scenario table out loud, two minutes each, and one answer comparing Bootstrap with a utility-first framework.
Bootstrap often appears inside a broader frontend loop; frontend developer interview questions covers the rest of it, and HTML interview questions covers the semantics that Bootstrap markup should respect.
Layout questions are easy to answer with class names alone, and interviewers then ask what the CSS does. Natively, an AI interview assistant for Mac and Windows, transcribes a mock frontend round on your computer so you can check whether you explained the why behind each class. During practice it can read a mockup or a code snippet from a screenshot and help with the markup, and with Pro or the free trial it can use the résumé and job description you add. You keep the transcript and notes to review.
Questions people ask
What Bootstrap questions are asked in frontend interviews?
How the 12-column grid and breakpoints work, containers and gutters, mobile-first column classes, utility classes, modals, dropdowns and tooltip initialization, form validation styles, Sass customization and differences between Bootstrap 4 and 5.
How do I customize Bootstrap the right way?
Override Sass variables before importing Bootstrap, extend maps such as theme colors, import only the parts you use, and use the generated CSS variables for runtime changes instead of overriding component classes.
Why does my Bootstrap tooltip not show?
Tooltips and popovers are opt-in and must be initialized with JavaScript. Disabled elements also do not fire the events a tooltip needs, so wrap them in another element.
Should I learn Bootstrap or Tailwind for interviews?
Learn the one the job uses, and be ready to compare them: Bootstrap gives ready components and a theme system, Tailwind gives utility classes for building custom designs.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
