Episode 1 — Fundamentals / 1.11 — CSS Frameworks TailwindCSS and Bootstrap
Interview Questions: CSS Frameworks — TailwindCSS & Bootstrap
Practice questions with model answers for CSS framework concepts, Tailwind utilities, Bootstrap grid, customization, and trade-offs — topics commonly asked in front-end and full-stack interviews.
How to use this material (instructions)
- Read lessons in order —
README.md, then1.11.a→1.11.h. - Practice out loud — aim for 1–2 minutes per question, then compare to the model answer.
- Structure answers — definition → example → trade-off.
- Pair with exercises —
1.11-Exercise-Questions.md. - Quick review —
1.11-Quick-Revision.md.
Beginner (Q1–Q6)
Q1. What is a CSS framework, and why would you use one?
Why interviewers ask: Tests whether you understand the purpose of tooling vs raw CSS and can articulate trade-offs.
Model answer:
A CSS framework is a collection of pre-written CSS (and sometimes JavaScript) that provides ready-made styles, a layout system, and design tokens (spacing, colors, breakpoints). You use one to:
- Ship faster — common patterns (buttons, grids, forms) are already built
- Enforce consistency — shared design tokens prevent ad hoc values
- Handle responsiveness — breakpoint systems are built in
- Reduce team friction — new developers follow existing conventions
The trade-off: you accept a learning curve, potential bundle size overhead, and dependency on the framework's release cycle. Understanding vanilla CSS remains essential — frameworks abstract CSS, and debugging requires knowing what's underneath.
Q2. What is utility-first CSS? How does it differ from component-based CSS?
Why interviewers ask: The utility vs component distinction is the most important architectural decision when choosing a framework.
Model answer:
| Approach | How it works | Example |
|---|---|---|
| Utility-first | Small, single-purpose classes composed in HTML | class="bg-blue-600 text-white p-4 rounded" |
| Component-based | Pre-styled, named classes applied to elements | class="btn btn-primary" |
Utility-first (Tailwind) gives you maximum design freedom but verbose HTML. You never invent class names — every CSS property has a corresponding utility. Production bundles are tiny because unused classes are purged.
Component-based (Bootstrap) gives you pre-built widgets — buttons, modals, navbars — with clean, short HTML. You can prototype quickly, but customizing deeply means overriding nested selectors and fighting specificity.
Neither is inherently better — utility-first suits custom designs and modern component frameworks; component-based suits rapid prototyping and teams that need pre-built UI.
Q3. How does Tailwind handle responsive design?
Why interviewers ask: Responsive design is table stakes — tests whether you understand Tailwind's mobile-first breakpoint system.
Model answer:
Tailwind uses a mobile-first approach with responsive prefixes:
| Prefix | Min-width | Meaning |
|---|---|---|
| (none) | 0 | Base (mobile) — applies at all sizes |
sm: | 640px | Small screens and above |
md: | 768px | Medium (tablets) and above |
lg: | 1024px | Large (laptops) and above |
xl: | 1280px | Extra large and above |
How to read it: md:flex-row means "apply flex-direction: row at 768px and above." Below that, the element uses whatever the unprefixed (mobile) style is.
<!-- Single column on mobile, two columns at md, three at lg -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
...
</div>
You write the smallest screen first (no prefix), then add prefixed overrides for larger screens. This is the opposite of "desktop-first" where you'd write large styles and then override for mobile.
Q4. Explain Bootstrap's grid system.
Why interviewers ask: The 12-column grid is Bootstrap's most important feature — interviewers want to see you understand the abstraction and can use it correctly.
Model answer:
Bootstrap uses a 12-column flexbox grid with three layers:
.container → Centers content, sets max-width per breakpoint
└── .row → Creates a flex container (with negative margins for gutters)
└── .col-* → Defines column width (1–12 out of 12 total)
Why 12? It divides evenly into halves (6+6), thirds (4+4+4), quarters (3+3+3+3), and sixths (2×6) — no fractional math.
Responsive column classes use the pattern col-{breakpoint}-{span}:
<div class="container">
<div class="row">
<div class="col-12 col-md-6 col-lg-4">A</div>
<div class="col-12 col-md-6 col-lg-4">B</div>
<div class="col-12 col-md-12 col-lg-4">C</div>
</div>
</div>
This creates full-width cards on mobile, two per row on tablets, three per row on desktops. Additional features include offsets (push columns right), order (rearrange visual sequence), and nesting (a new 12-column context inside any column).
Q5. How do you install and set up TailwindCSS in a project?
Why interviewers ask: Practical setup knowledge shows you've actually used the tool, not just read about it.
Model answer:
npm install -D tailwindcss
npx tailwindcss init
This creates tailwind.config.js. Configure the content paths so Tailwind knows which files to scan for class names:
module.exports = {
content: ["./src/**/*.{html,js,jsx,tsx}"],
theme: { extend: {} },
plugins: [],
};
Add Tailwind directives to your CSS entry file:
@tailwind base;
@tailwind components;
@tailwind utilities;
Build with: npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch
With a bundler (Vite, Webpack): npx tailwindcss init -p also creates postcss.config.js and the bundler processes Tailwind through PostCSS automatically.
The content array is critical — any class name not found in scanned files is removed from production CSS, keeping the bundle small (typically 5–15 KB gzipped).
Q6. What are Bootstrap's key components? Name five and describe each in one sentence.
Why interviewers ask: Tests practical knowledge of what Bootstrap offers out of the box.
Model answer:
| Component | Description |
|---|---|
| Navbar | Responsive navigation bar that collapses into a hamburger menu on small screens |
| Card | Flexible content container with header, body, footer, and image regions |
| Modal | Dialog overlay with built-in focus trapping, backdrop, and keyboard handling |
| Alert | Dismissible notification banner with color variants for success, danger, warning, info |
| Form controls | Styled inputs, selects, checkboxes, and radios with consistent sizing and validation states |
Additional notable components: Buttons (.btn-primary, .btn-outline-*, sizes), Badge (small labels/counters), Spinner (loading indicators), Tooltip/Popover (contextual overlays using Popper.js), and Accordion (collapsible content panels).
Intermediate (Q7–Q11)
Q7. How do you customize Bootstrap's default theme?
Why interviewers ask: Using Bootstrap without customization signals "tutorial-level" experience; interviewers want to see you know how to make it your own.
Model answer:
Bootstrap is customized primarily through SASS variable overrides. You define your variables before importing Bootstrap:
$primary: #6366f1;
$border-radius: 0.75rem;
$font-family-base: "Inter", sans-serif;
@import "bootstrap/scss/bootstrap";
This works because Bootstrap declares all variables with !default, meaning "use this value unless it's already defined." Your earlier definitions take precedence.
Three levels of customization:
- SASS variables — colors, spacing, fonts, border-radius (easiest, most impactful)
- Cherry-picking imports — import only the components you use (reduces bundle 50–70%)
- Utilities API — generate custom utility classes following Bootstrap's naming conventions
For runtime theming without recompilation, Bootstrap 5 exposes CSS custom properties (--bs-primary, --bs-body-bg) that can be overridden in CSS.
Q8. What is Tailwind's @apply directive, and when should you use it?
Why interviewers ask: Tests whether you understand Tailwind's escape hatch and its trade-offs.
Model answer:
@apply lets you extract repeated Tailwind utility patterns into custom CSS classes:
.btn-primary {
@apply bg-blue-600 text-white font-semibold py-2 px-4 rounded-lg
hover:bg-blue-700 focus:ring-2 focus:ring-blue-500;
}
When to use it:
- Global styles that can't be components (third-party widget styling, base element resets)
- Styles applied to elements you don't control (CMS output, markdown rendering)
When to avoid it:
- Reusable UI components — extract into framework components (React, Vue, Svelte) instead
- Overusing
@applyrecreates the problems Tailwind solves — hidden styles, naming fatigue, and CSS that grows unboundedly
The preferred reuse pattern in Tailwind is component abstraction at the framework level, not CSS-level abstraction with @apply.
Q9. Compare the production bundle sizes of Tailwind and Bootstrap.
Why interviewers ask: Bundle size directly impacts performance — shows you think about what ships to users.
Model answer:
| Metric | Tailwind | Bootstrap |
|---|---|---|
| Dev (all classes) | ~3+ MB | ~230 KB |
| Production | ~5–15 KB gzipped | ~25 KB gzipped (full) |
| Optimized | Always purged (build step) | ~10–15 KB (cherry-picked SASS) |
Why Tailwind is smaller: The build tool scans your files and includes only the classes you actually used. A project using 200 utilities ships only those 200, regardless of the thousands available.
Why Bootstrap is larger: The default CSS ships every component — navbar, modal, carousel, accordion — whether you use them or not. You can reduce this by cherry-picking SASS imports, but it requires manual effort.
Key insight: Tailwind's production size scales with your usage; Bootstrap's scales with what you exclude. For typical projects, both can reach ~10–15 KB gzipped with effort, but Tailwind achieves it automatically.
Q10. How would you implement dark mode with Tailwind vs Bootstrap?
Why interviewers ask: Dark mode is a common requirement — tests practical implementation knowledge with each framework.
Model answer:
Tailwind:
// tailwind.config.js
module.exports = { darkMode: "class" }; // or "media"
<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
Dark mode content
</div>
"media"— follows OSprefers-color-schemeautomatically"class"— requires addingclass="dark"to a parent element (JavaScript toggle)
Bootstrap:
Bootstrap 5.3+ added a data-bs-theme attribute:
<html data-bs-theme="dark">
For earlier versions or custom themes, you override CSS custom properties:
[data-theme="dark"] {
--bs-body-bg: #0f172a;
--bs-body-color: #e2e8f0;
}
Comparison: Tailwind's dark: variant is more granular — you control dark styles per element. Bootstrap's approach is more global — you toggle a theme attribute and components adapt. Tailwind requires more markup; Bootstrap provides less per-element control.
Q11. When would you choose Tailwind over Bootstrap, and vice versa?
Why interviewers ask: This is the most common CSS framework interview question — tests decision-making ability, not just framework knowledge.
Model answer:
Choose Tailwind when:
- You need to match a custom design (Figma mockup, brand guidelines)
- You're using a modern component framework (React, Vue, Svelte) for reuse
- Bundle size is critical (performance-sensitive apps)
- The project will be maintained long-term (explicit styles are easier to refactor)
Choose Bootstrap when:
- You need to ship fast (MVP, prototype, hackathon)
- Building admin panels or internal tools with many tables, forms, and modals
- The team is less experienced with CSS (pre-built components lower the barrier)
- You want interactive components without building them (modals, tooltips, carousels)
- No build step is available (CDN installation)
Key principle: Tailwind optimizes for design freedom and long-term maintainability; Bootstrap optimizes for speed-to-ship and pre-built functionality. The right choice depends on the project, not the framework.
Advanced / Scenario (Q12–Q15)
Q12. A product team says "we want to use both Tailwind and Bootstrap." How would you respond?
Why interviewers ask: Tests your ability to push back on technical decisions with reasoned arguments.
Model answer:
I would recommend against it and explain three specific risks:
-
Conflicting CSS resets — both frameworks normalize browser defaults differently. Running both can cause unpredictable base styles (font sizes, margins, link colors).
-
Doubled bundle size — you're shipping two CSS frameworks. Even with Tailwind's purging, Bootstrap's full component CSS still loads. Users pay for both.
-
Class name conflicts — some utility names overlap (
p-4,text-center,d-flex). Developers won't know which framework is styling what, making debugging harder.
Alternative approaches:
- Pick one framework and extend it (Tailwind + Headless UI for components, or Bootstrap + custom utilities)
- If you need specific Bootstrap components (e.g., a modal), copy the relevant CSS rather than importing the entire library
- If the team is split, align on one framework and invest in training
Q13. You inherit a Bootstrap project with a 300 KB CSS bundle. How would you reduce it?
Why interviewers ask: Tests performance optimization knowledge applied to a real-world framework scenario.
Model answer:
Step 1 — Audit usage: Run PurgeCSS or a coverage tool (Chrome DevTools → Coverage tab) to identify unused CSS. Typical Bootstrap projects use < 30% of the shipped CSS.
Step 2 — Cherry-pick SASS imports: Replace the full @import "bootstrap" with individual component imports:
@import "bootstrap/scss/functions";
@import "bootstrap/scss/variables";
@import "bootstrap/scss/mixins";
@import "bootstrap/scss/reboot";
@import "bootstrap/scss/grid";
@import "bootstrap/scss/buttons";
// ... only what you need
Step 3 — Remove JavaScript you don't use: If you don't have tooltips, carousels, or popovers, don't import bootstrap.bundle.js. Import only the specific JS plugins needed.
Step 4 — PurgeCSS as PostCSS plugin: Configure PurgeCSS to scan your templates and strip any classes not found in your HTML/JS files.
Step 5 — Minify + compress: Ensure CSS is minified and served with gzip/brotli compression.
Expected result: 300 KB → 30–50 KB uncompressed → ~8–12 KB gzipped.
Q14. Explain how Tailwind's JIT (Just-In-Time) engine works and why it matters.
Why interviewers ask: Advanced Tailwind knowledge — shows you understand the build process, not just the classes.
Model answer:
Before JIT (Tailwind v2 and earlier), Tailwind generated every possible class during development — a massive CSS file (3+ MB). PurgeCSS removed unused classes for production.
JIT (Tailwind v3+) flips this: it generates classes on demand as you use them. The build tool watches your files and only generates the CSS for classes it actually finds.
Why it matters:
| Benefit | Detail |
|---|---|
| Instant dev builds | No waiting for 3+ MB to compile; only used classes are generated |
| Arbitrary values | w-[37px], bg-[#1da1f2] — any value, no config needed |
| Every variant works | hover:first:bg-blue-500 — no need to enable variants in config |
| Identical dev/prod | What you see in dev is exactly what ships; no purge surprises |
JIT made Tailwind significantly faster to work with and removed the need for explicit variant configuration.
Q15. Design a CSS framework strategy for a company with 10 frontend teams building different products.
Why interviewers ask: Tests architectural thinking — framework choice at scale involves more than personal preference.
Model answer:
Recommendation: Tailwind with a shared design system config.
- Shared
tailwind.config.jspreset — publish as an npm package containing brand colors, fonts, spacing scale, and custom plugins. All teams install it:
// Each team's tailwind.config.js
module.exports = {
presets: [require("@company/tailwind-preset")],
content: ["./src/**/*.{js,tsx}"],
};
-
Shared component library — build common components (Button, Input, Card, Modal) as React/Vue components using Tailwind classes. Publish as a package. Teams compose with these or build custom UI.
-
Why not Bootstrap? With 10 teams, Bootstrap's component styles would need heavy SASS customization per team, and keeping overrides synchronized is harder than sharing a config. Tailwind's config-driven approach means brand consistency is one file.
-
Governance:
- Design system team maintains the preset and component library
- Teams can
extendthe preset for product-specific tokens - Lint rules enforce usage of design tokens over arbitrary values
-
Migration path — teams already on Bootstrap can adopt Tailwind incrementally; they coexist during migration (with care about CSS resets).
Quick-Fire (Yes / No + one line)
| Question | Answer | One-line rationale |
|---|---|---|
| Does Tailwind include pre-built JavaScript components? | No | Tailwind is CSS-only; use Headless UI or similar for behavior. |
| Does Bootstrap 5 require jQuery? | No | jQuery dependency was dropped in Bootstrap 5. |
Can Tailwind generate classes for arbitrary values like w-[37px]? | Yes | JIT engine generates any value wrapped in brackets on demand. |
Is @apply the recommended way to reuse Tailwind patterns? | No | Prefer framework-level components (React, Vue); @apply is an escape hatch. |
| Does Bootstrap's CDN installation require a build step? | No | One <link> and one <script> tag in your HTML. |
| Can you add custom theme colors to Bootstrap's SASS map? | Yes | Use map-merge($theme-colors, $custom-colors) before the import. |
Is Tailwind's md: prefix "at exactly 768px"? | No | It means "768px and above" — it's a min-width media query. |
| Does using a CSS framework eliminate the need to learn CSS? | No | Debugging and customization require understanding the CSS underneath. |
Interview Tips
- Name the trade-off. "Tailwind gives design freedom but verbose HTML; Bootstrap gives speed but less customization" — always show both sides.
- Give a concrete example. "I'd choose Bootstrap for an admin dashboard because it ships forms, tables, and modals ready to use."
- Mention bundle size. Performance-aware answers stand out — "Tailwind purges to ~10 KB; Bootstrap ships ~25 KB unless you cherry-pick."
- Connect to real decisions. "On my last project, we chose Tailwind because the design was custom and we were using React for component reuse."
- Know the latest versions. Bootstrap 5 dropped jQuery; Tailwind v3+ uses JIT by default. Outdated knowledge signals stale experience.
- Accessibility still matters. "Bootstrap's modal handles focus trapping automatically; with Tailwind, I'd use Headless UI for that."
- Don't be dogmatic. Interviewers respect balanced opinions more than tribal loyalty to one framework.
Use this alongside the 1.11 Exercise Questions for hands-on practice and deeper review.