Skip to content
Tutorials Center
My learning

Topics

Lesson 57 of 58 ยท Practice and Review

Bootstrap Interview Questions

Bootstrap 5.3 interview questions with short, accurate answers on the grid, breakpoints, utilities, JavaScript plugins, Sass, accessibility and Tailwind.

Bootstrap interviews are usually not about remembering class names. They check whether you understand the ideas behind them: why the grid has twelve columns, what "mobile first" really means in CSS, when a plugin needs JavaScript, and when a utility framework is the wrong tool. The answers below are short enough to say out loud in under a minute, and each points to the lesson that explains the topic in full.

How to use this page: read the question, answer it in your own words, then compare. Bold phrases are the points an interviewer listens for. Two small live demos prove the answers that people most often get wrong. Everything targets Bootstrap 5.3.

Fundamentals

1. What is Bootstrap and what does it include?

Bootstrap is a front-end toolkit of CSS, Sass source and optional JavaScript plugins. It gives you a reset (Reboot), a responsive grid, typography, utilities, form styles and ready-made components such as navbars, cards and modals. See Introduction to Bootstrap.

2. Does Bootstrap 5 need jQuery?

No. Version 5 removed the jQuery dependency; the plugins are plain JavaScript. They work with data-bs-* attributes or through the bootstrap global (for example new bootstrap.Modal(el)). Bootstrap 4 required jQuery. See Bootstrap JavaScript Plugins.

3. What is the viewport meta tag and why is it required?

<meta name="viewport" content="width=device-width, initial-scale=1"> tells mobile browsers to use the device width as the layout width instead of pretending to be a 980 px desktop. Without it, the responsive breakpoints never match on phones. Also add the HTML5 doctype so the browser does not enter quirks mode. See Installing Bootstrap.

4. What does Reboot do?

Reboot is a thin normalization layer built on top of the standard reset. It sets box-sizing: border-box globally, removes default margins from many elements, uses a native font stack and gives headings and lists consistent spacing. It is why a bare page already looks tidy. See Your First Bootstrap Page.

Grid and breakpoints

5. How does the grid work?

A .container limits the width, a .row is a flex container, and .col-* children share twelve units per row. A column spanning 4 takes a third. If the columns in a row add up to more than 12, the extra ones wrap to a new line. See The Grid System.

6. Why twelve columns?

Twelve divides evenly by 1, 2, 3, 4, 6 and 12, so halves, thirds, quarters and sixths all line up without fractions.

7. What are the six breakpoints?

Name Class infix Minimum width
Extra small none 0
Small sm 576 px
Medium md 768 px
Large lg 992 px
Extra large xl 1200 px
Extra extra large xxl 1400 px

See Breakpoints and Responsive Design.

8. What does "mobile first" mean in practice?

Bootstrap writes its media queries with min-width. A class without an infix applies at every size, and an infix class such as col-md-6 applies from md upward. You design the small layout first and add changes for larger screens. col-md-6 does not mean "only on medium screens"; it also applies on lg, xl and xxl unless something more specific overrides it.

flowchart LR
  A["col-12<br/>all sizes"] --> B["col-md-6<br/>from 768px"]
  B --> C["col-xl-4<br/>from 1200px"]

Each larger class takes over from its breakpoint; the smaller one is still the fallback.

9. Show a layout that is stacked on phones and has three columns on desktop.

Give a column col-12 col-lg-4. The live demo below prints the active layout so you can see the classes switch as you resize the preview.

Mobile-first columns

10. What is the difference between .container and .container-fluid?

.container has a fixed max-width at each breakpoint (540, 720, 960, 1140 and 1320 px from sm upward) and is centered. .container-fluid is always 100% wide. .container-md is 100% wide until md, then behaves like a fixed container. See Containers.

11. What are gutters and how do you change them?

Gutters are the padding between columns (1.5 rem by default). Use g-* for both directions, gx-* horizontally, gy-* vertically, and g-0 to remove them. The row compensates with negative margins, which is why a row outside a container can cause horizontal scrolling. See Gutters, Alignment and Ordering.

12. How do you reorder or offset a column?

order-* (with responsive variants) changes visual order, offset-* pushes a column to the right by empty columns, and ms-auto pushes it to the end with an auto margin. Remember that reordering is visual only; the DOM and keyboard order stay the same.

13. What is row-cols-*?

It sets how many equal columns fit in a row on the row itself, such as row-cols-1 row-cols-md-3, so children only need .col. It is the quickest way to make card grids.

14. When would you use Bootstrap's CSS Grid option instead of the flexbox grid?

The optional CSS Grid layout (.grid, .g-col-*) is for two-dimensional placement, such as dashboards where items span rows and columns. The default flex grid is better for one-dimensional rows and has the widest example base. See Nested Grids and Full Layouts.

Utilities and content

15. What is the spacing scale?

Spacing utilities follow {sides}-{breakpoint}-{size}. Property is m or p; sides are t, b, s, e, x or y; sizes 0 to 5 map to 0, 0.25, 0.5, 1, 1.5 and 3 rem. auto is available for margins. s and e mean start and end, so they flip in right-to-left layouts. See Spacing Utilities.

16. How do you hide an element on small screens only?

Combine display utilities: d-none d-md-block hides it below md and shows it from md. To hide it only on one range, use d-md-none d-lg-block-style pairs. See Display and Visibility.

17. What is the difference between d-none and invisible?

d-none is display: none, so the element takes no space and is hidden from assistive technology. invisible is visibility: hidden: it keeps its space, and it is also hidden from screen readers. Use visually-hidden to hide something visually but keep it for screen readers.

18. Why do utilities beat component styles?

Bootstrap generates utilities with !important, so mb-0 or text-center wins even over a component rule that sets a margin or alignment. That makes them easy to apply but harder to override from your own CSS. See The Utility API.

19. How do you center something?

For text, text-center. For a block with a width, mx-auto. For both axes, a flex parent with d-flex justify-content-center align-items-center. See Flex Utilities.

20. How do you make an image responsive?

Add .img-fluid (max-width: 100%; height: auto). For fixed aspect boxes use .ratio ratio-16x9. See Images and Figures.

JavaScript plugins

21. Which components need JavaScript?

Modal, collapse (and so accordion and navbar toggler), dropdown, offcanvas, carousel, tooltip, popover, toast, scrollspy, tab and alert dismissal. Pure CSS components are buttons, cards, badges, list groups, forms, tables and the grid. Tooltips, popovers and dropdowns depend on Popper.

22. What is the difference between bootstrap.bundle.js and bootstrap.js?

The bundle includes Popper, so dropdowns, tooltips and popovers work from one file. bootstrap.js alone does not include Popper, so you would need to load it first.

23. Are tooltips and popovers enabled automatically?

No. For performance they are opt-in. Put data-bs-toggle="tooltip" on the element and create instances with JavaScript. The demo shows the pattern and a state you can check:

Opt-in tooltips and events

Without the script, the attribute does nothing. See Dropdowns, Tooltips and Popovers.

24. How do you control a plugin from JavaScript?

Get the instance with bootstrap.Modal.getOrCreateInstance(element) and call show(), hide(), toggle() or dispose(). Listen to events like show.bs.modal and hidden.bs.modal; calling event.preventDefault() in a show or hide handler cancels the action. See Plugin Events and Programmatic Control.

25. How do you pass data to a modal?

Put data-* attributes on the trigger button, read them in the modal's show.bs.modal handler via event.relatedTarget, and write them into the modal with textContent. See Modals.

Customizing

26. How can you customize Bootstrap without Sass?

Override the CSS variables (--bs-primary, --bs-body-font-family, --bs-border-radius, and component variables such as --bs-btn-bg) on :root or on a single element. See Customizing with CSS Variables.

27. How do you customize it with Sass?

Install bootstrap through npm, define your own values before importing Bootstrap's Sass (variables use !default), merge into maps like $theme-colors, and import only the partials you need. Remember that Bootstrap's @import workflow is being phased out in Sass in favor of modules, so check the current Bootstrap docs for the recommended syntax. See Customizing with Sass.

28. How does dark mode work in 5.3?

Set data-bs-theme="dark" on <html> or any element. The color variables switch for that subtree, so you can mix themes on one page. Bootstrap does not detect prefers-color-scheme by itself; a small script does that. See Color Modes and Dark Mode.

Quality and comparisons

29. How do you keep Bootstrap accessible?

Use semantic elements first, keep labels on form fields, give modals aria-labelledby, keep the visible focus ring, use visually-hidden for text-only cues, check color contrast of custom colors and respect prefers-reduced-motion. Bootstrap's components set many ARIA attributes for you, but they cannot fix wrong content. See Accessibility in Bootstrap.

30. Bootstrap or Tailwind CSS?

Bootstrap ships ready-made components and conventions, so a team gets a consistent look quickly. Tailwind ships only low-level utilities, and you build the components yourself with a build step that prunes unused CSS. Bootstrap's sites can look alike unless themed; Tailwind needs more design decisions up front. Bootstrap fits admin tools, prototypes and teams without a designer; Tailwind fits custom designs. Both can be used well. See Introduction to Bootstrap and Performance and Best Practices.

31. What changed from Bootstrap 4 to 5?

jQuery and Internet Explorer support were removed, ml-*/mr-* became ms-*/me-*, data-toggle became data-bs-toggle, forms were simplified (form-group is gone), the utility API arrived, and RTL support was added. See Migrating from Bootstrap 4 and Using Icons.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A column has the class col-md-6. At which widths does it take half the row?

    Bootstrap is mobile first and uses min-width queries, so md classes apply from 768px upward.
  2. 2. Which statement about tooltips in Bootstrap 5.3 is correct?

    Tooltips and popovers are opt-in for performance. You create an instance, for example with getOrCreateInstance.
  3. 3. What is the difference between d-none and invisible?

    d-none sets display: none. invisible sets visibility: hidden, so the layout space remains.
  4. 4. Why can a .row placed directly in <body> cause horizontal scrolling?

    The row's negative margins offset the columns' gutter padding; without a container's padding they extend past the edge.

Summary

  • Know the six breakpoints, the 12-column grid and what mobile first means.
  • Utilities are generated with !important; d-none and invisible behave differently.
  • Plugins are jQuery-free; tooltips and popovers are opt-in and need Popper (inside the bundle).
  • Customize with CSS variables first, Sass when you need to change the build.
  • Be ready to compare Bootstrap with Tailwind honestly: components versus utilities.

Next lesson: Bootstrap Cheat Sheet.