Bird
Raised Fist0
Bootsrapmarkup~20 mins

Striped and hover tables in Bootsrap - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Bootstrap Table Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate
2:00remaining
What visual effect does the .table-striped class add to a Bootstrap table?
Look at a Bootstrap table with the .table-striped class applied. What will you see when the table is rendered in a browser?
Bootsrap
<table class="table table-striped">
  <thead>
    <tr><th>#</th><th>Name</th></tr>
  </thead>
  <tbody>
    <tr><td>1</td><td>Alice</td></tr>
    <tr><td>2</td><td>Bob</td></tr>
    <tr><td>3</td><td>Carol</td></tr>
  </tbody>
</table>
ATable header cells become bold and underlined.
BRows alternate background colors, making every other row shaded differently.
CRows highlight with a color when hovered by the mouse pointer.
DTable borders become thicker and darker.
Attempts:
2 left
💡 Hint
Think about how to make reading rows easier by changing backgrounds.
❓ rendering
intermediate
2:00remaining
What does the .table-hover class do in a Bootstrap table?
Given a Bootstrap table with the .table-hover class, what visual effect will you see when you move your mouse over the rows?
Bootsrap
<table class="table table-hover">
  <thead>
    <tr><th>ID</th><th>City</th></tr>
  </thead>
  <tbody>
    <tr><td>1</td><td>Paris</td></tr>
    <tr><td>2</td><td>London</td></tr>
    <tr><td>3</td><td>Tokyo</td></tr>
  </tbody>
</table>
ATable header cells become clickable buttons.
BRows have alternating background colors by default.
CRows change background color when hovered by the mouse pointer.
DTable rows become bold when clicked.
Attempts:
2 left
💡 Hint
Hover means moving the mouse over something.
❓ selector
advanced
2:00remaining
Which CSS selector does Bootstrap use internally to apply the hover effect for .table-hover?
Bootstrap applies a background color on table rows when hovered using a CSS selector. Which selector correctly targets the rows inside a table with .table-hover?
A.table-hover tbody tr:hover
B.table-hover tr:hover
Ctbody tr:hover
D.table-hover > tr:hover
Attempts:
2 left
💡 Hint
Think about which rows inside the table body get hovered.
❓ layout
advanced
2:00remaining
How do .table-striped and .table-hover classes interact when both are applied to a Bootstrap table?
If you add both .table-striped and .table-hover classes to a Bootstrap table, what will be the combined visual effect?
Bootsrap
<table class="table table-striped table-hover">
  <thead>
    <tr><th>#</th><th>Item</th></tr>
  </thead>
  <tbody>
    <tr><td>1</td><td>Pen</td></tr>
    <tr><td>2</td><td>Notebook</td></tr>
    <tr><td>3</td><td>Eraser</td></tr>
  </tbody>
</table>
ARows alternate background colors, but hover effect changes text color instead of background.
BOnly the striped effect works; hover effect is ignored.
COnly the hover effect works; striped rows are not visible.
DRows alternate background colors, and the hovered row changes background color on mouse hover.
Attempts:
2 left
💡 Hint
Both classes add different background color effects.
❓ accessibility
expert
3:00remaining
Which ARIA role and attribute best improve accessibility for a Bootstrap table with striped and hover effects?
To make a Bootstrap table with .table-striped and .table-hover accessible for screen readers and keyboard users, which ARIA role and attribute combination is most appropriate?
Bootsrap
<table class="table table-striped table-hover" ... >
  ...
</table>
AAdd <code>role="grid"</code> and <code>aria-rowcount</code> to indicate row count.
BAdd <code>aria-live="polite"</code> to announce row changes dynamically.
CAdd <code>role="presentation"</code> to hide the table from assistive tech.
DAdd <code>role="list"</code> to treat the table as a list.
Attempts:
2 left
💡 Hint
Think about roles that describe tables and their structure.

Practice

(1/5)
1. What does the table-striped class do in a Bootstrap table?
easy
A. Adds alternating background colors to table rows for easier reading.
B. Highlights the row when you hover the mouse over it.
C. Makes the table borders thicker.
D. Changes the font style of the table text.

Solution

  1. Step 1: Understand the purpose of table-striped

    The table-striped class adds alternating background colors to rows, making it easier to read data across the table.
  2. Step 2: Differentiate from other classes

    The table-hover class highlights rows on mouse hover, which is different from table-striped.
  3. Final Answer:

    Adds alternating background colors to table rows for easier reading. -> Option A
  4. Quick Check:

    Striped = alternating row colors [OK]
Hint: Striped means alternating colors on rows [OK]
Common Mistakes:
  • Confusing striped with hover effect
  • Thinking it changes font or borders
  • Assuming it highlights on mouse hover
2. Which is the correct way to add both striped and hover effects to a Bootstrap table?
easy
A. <table class='table-striped-hover'>
B. <table class='table-hover table-striped'>
C. <table class='striped hover'>
D. <table class='table table-striped table-hover'>

Solution

  1. Step 1: Check Bootstrap class syntax

    Bootstrap requires the base table class plus additional classes separated by spaces, like table-striped and table-hover.
  2. Step 2: Validate correct class order and spelling

    <table class='table table-striped table-hover'> correctly uses class='table table-striped table-hover'. Order doesn't matter but all classes must be present and spelled correctly.
  3. Final Answer:

    <table class='table table-striped table-hover'> -> Option D
  4. Quick Check:

    Use base table plus both classes [OK]
Hint: Always include base 'table' class with modifiers [OK]
Common Mistakes:
  • Omitting the base 'table' class
  • Combining classes without spaces
  • Using incorrect class names
3. Given this HTML snippet, what visual effect will the table have?
<table class='table table-striped table-hover'>
  <tr><td>Row 1</td></tr>
  <tr><td>Row 2</td></tr>
  <tr><td>Row 3</td></tr>
</table>
medium
A. Rows alternate background colors and highlight on mouse hover.
B. Rows have no background color but highlight on mouse hover.
C. Rows alternate background colors but do not highlight on hover.
D. Table has no special background or hover effects.

Solution

  1. Step 1: Identify classes used

    The table uses table-striped and table-hover classes together.
  2. Step 2: Understand combined effects

    table-striped adds alternating row colors, and table-hover highlights the row under the mouse pointer.
  3. Final Answer:

    Rows alternate background colors and highlight on mouse hover. -> Option A
  4. Quick Check:

    Striped + Hover = alternating colors + highlight [OK]
Hint: Both classes combine their effects visually [OK]
Common Mistakes:
  • Thinking only one effect applies
  • Ignoring hover effect
  • Confusing hover with striped effect
4. What is wrong with this table code if the hover effect does not work?
<table class='table table-striped hover'>
  <tr><td>Data</td></tr>
</table>
medium
A. The table-striped class disables hover effect.
B. The table class is missing.
C. The class should be table-hover, not just hover.
D. Hover effect requires JavaScript to work.

Solution

  1. Step 1: Check class names

    The class hover alone is not a valid Bootstrap class for hover effect.
  2. Step 2: Correct class for hover effect

    The correct class is table-hover, which must be used with the base table class.
  3. Final Answer:

    The class should be table-hover, not just hover. -> Option C
  4. Quick Check:

    Hover effect needs table-hover class [OK]
Hint: Hover class must be 'table-hover' exactly [OK]
Common Mistakes:
  • Using 'hover' instead of 'table-hover'
  • Omitting 'table' base class
  • Assuming hover needs JavaScript
5. You want a table that has striped rows, highlights on hover, and also makes the header row stand out with a dark background. Which is the best way to achieve this using Bootstrap classes?
hard
A. <table class='table table-striped table-hover'> <thead class='table-header-dark'> ... </thead> </table>
B. <table class='table table-striped table-hover'> <thead class='table-dark'> ... </thead> </table>
C. <table class='table table-striped table-hover'> <thead class='thead-dark'> ... </thead> </table>
D. <table class='table table-striped table-hover table-dark'> ... </table>

Solution

  1. Step 1: Combine striped and hover classes on table

    Use table-striped and table-hover with the base table class for row effects.
  2. Step 2: Use correct class for dark header

    Bootstrap uses table-dark on the <thead> element to style the header with a dark background.
  3. Step 3: Verify other options

    table-dark on the whole table changes entire table style, not just header. thead-dark is deprecated in Bootstrap 5+. table-header-dark is not a valid class.
  4. Final Answer:

    <table class='table table-striped table-hover'> <thead class='table-dark'> ... </thead> </table> -> Option B
  5. Quick Check:

    Use table-dark on thead for dark header [OK]
Hint: Dark header uses 'table-dark' on thead element [OK]
Common Mistakes:
  • Applying 'table-dark' to whole table instead of header
  • Using deprecated 'thead-dark' class
  • Inventing non-existent classes like 'table-header-dark'
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard