A responsive table adjusts its layout to fit different screen sizes, making it easy to read on phones, tablets, and desktops without horizontal scrolling.
Click to reveal answer
beginner
How does Bootstrap make tables responsive?
Bootstrap wraps the table inside a <div class='table-responsive'> container. This container adds horizontal scrolling on small screens so the table fits nicely.
Click to reveal answer
beginner
Which Bootstrap class is used to make a table horizontally scrollable on small devices?
The class table-responsive is used on a container div around the table to enable horizontal scrolling on smaller screens.
Click to reveal answer
intermediate
Why is horizontal scrolling better than shrinking table columns too much on small screens?
Horizontal scrolling keeps the table content readable and avoids squishing text or data, which can make it hard to understand.
Click to reveal answer
beginner
What HTML structure is recommended for a responsive table in Bootstrap?
Wrap the <table> element inside a <div class='table-responsive'>. Inside the table, use Bootstrap classes like table for styling.
Click to reveal answer
Which Bootstrap class makes a table responsive by adding horizontal scrolling?
Ascroll-table
Btable-responsive
Cresponsive-table
Dtable-scroll
✗ Incorrect
The correct class is table-responsive. It wraps the table to add horizontal scrolling on small screens.
What happens to a table inside <div class='table-responsive'> on a small screen?
AIt gets horizontal scroll to view all columns
BIt becomes hidden
CIt shrinks columns to fit the screen
DIt converts to a list
✗ Incorrect
The table gets horizontal scrolling so users can swipe to see all columns without shrinking content.
Why should you avoid shrinking table columns too much on small screens?
AIt can make text hard to read
BIt makes the table load slower
CIt breaks the table structure
DIt disables scrolling
✗ Incorrect
Shrinking columns too much makes text and data hard to read, hurting usability.
Which HTML element should wrap the table to make it responsive in Bootstrap?
2. Which of the following is the correct way to make a Bootstrap table responsive?
easy
A. <div class='table-responsive'><table class='table'>...</table></div>
B. <table class='table-responsive table'>...</table>
C. <div class='responsive-table'><table class='table'>...</table></div>
D. <table class='table' responsive>...</table>
Solution
Step 1: Recall Bootstrap responsive table syntax
Bootstrap requires wrapping the <table> inside a <div> with class table-responsive.
Step 2: Check each option
<div class='table-responsive'><table class='table'>...</table></div> correctly wraps the table inside div.table-responsive. The other options use incorrect class names or attributes.
Final Answer:
<div class='table-responsive'><table class='table'>...</table></div> -> Option A
Quick Check:
Wrap table in div.table-responsive [OK]
Hint: Wrap tables in div.table-responsive for responsiveness [OK]
Common Mistakes:
Adding table-responsive directly to table
Using wrong class names like responsive-table
Using attributes instead of classes
3. What will happen when the following code is viewed on a small mobile screen?
A. The table columns will stack vertically automatically
B. The table will scroll horizontally if it doesn't fit the screen
C. The table will be hidden on small screens
D. The table will overflow outside the screen without scroll
Solution
Step 1: Understand table-responsive behavior
The table-responsive wrapper adds horizontal scrolling on small screens if the table is wider than the viewport.
Step 2: Analyze other options
The table columns do not stack vertically automatically (that requires other techniques). The table is not hidden, and it won't overflow without scroll because of the wrapper.
Final Answer:
The table will scroll horizontally if it doesn't fit the screen -> Option B
Quick Check:
Responsive tables scroll horizontally on small devices [OK]
Hint: Responsive tables scroll horizontally on small screens [OK]
Common Mistakes:
Thinking columns stack vertically automatically
Assuming table hides on small screens
Ignoring horizontal scroll behavior
4. You wrote this code but the table does not scroll on small screens:
A. Add inline style overflow-x: scroll; to the table
B. Add class table-responsive directly to the table
C. Wrap the table inside a div with class table-responsive
D. Replace table-bordered with table-responsive
Solution
Step 1: Identify missing wrapper
The table is missing the required div.table-responsive wrapper that enables horizontal scrolling on small screens.
Step 2: Evaluate other options
Adding table-responsive class directly to table or replacing table-bordered is incorrect. Inline styles on table won't work properly for responsiveness.
Final Answer:
Wrap the table inside a div with class table-responsive -> Option C
Quick Check:
Wrap tables in div.table-responsive for scroll [OK]
Hint: Always wrap tables in div.table-responsive for scrolling [OK]
Common Mistakes:
Adding table-responsive class to table instead of wrapper
Removing other styling classes
Using inline styles on table instead of wrapper
5. You want to create a responsive table that has striped rows and borders, but only scrolls horizontally on screens smaller than medium size (less than 768px). Which Bootstrap class should you use to wrap the table?