0
0
Tailwindmarkup~20 mins

Table and data grid patterns in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
šŸŽ–ļø
Table Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā“ rendering
intermediate
2:00remaining
Responsive Table Layout with Tailwind CSS
Which option correctly creates a responsive table that scrolls horizontally on small screens using Tailwind CSS?
A<div class="overflow-x-auto"><table class="min-w-full border-collapse border border-gray-300"><thead><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th><th class="border border-gray-300 p-2">City</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td><td class="border border-gray-300 p-2">New York</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td><td class="border border-gray-300 p-2">Chicago</td></tr></tbody></table></div>
B<div class="overflow-x-scroll"><table class="min-w-full border-collapse border border-gray-300"><thead><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th><th class="border border-gray-300 p-2">City</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td><td class="border border-gray-300 p-2">New York</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td><td class="border border-gray-300 p-2">Chicago</td></tr></tbody></table></div>
C<div class="overflow-auto"><table class="w-full border-collapse border border-gray-300"><thead><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th><th class="border border-gray-300 p-2">City</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td><td class="border border-gray-300 p-2">New York</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td><td class="border border-gray-300 p-2">Chicago</td></tr></tbody></table></div>
D<table class="min-w-full overflow-x-auto border-collapse border border-gray-300"><thead><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th><th class="border border-gray-300 p-2">City</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td><td class="border border-gray-300 p-2">New York</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td><td class="border border-gray-300 p-2">Chicago</td></tr></tbody></table>
Attempts:
2 left
šŸ’” Hint
Wrap the table in a container that allows horizontal scrolling on small screens.
ā“ selector
intermediate
1:30remaining
Tailwind CSS Selector for Zebra Striping Table Rows
Which Tailwind CSS utility class correctly applies zebra striping (alternating row background colors) to table rows?
AUse <code>first:bg-gray-100</code> on <code>&lt;tr&gt;</code> elements
BUse <code>even:bg-gray-100</code> on <code>&lt;tbody&gt;</code> element
CUse <code>odd:bg-gray-100</code> on <code>&lt;tr&gt;</code> elements
DUse <code>last:bg-gray-100</code> on <code>&lt;tbody&gt;</code> element
Attempts:
2 left
šŸ’” Hint
Zebra striping changes background color on alternating rows, starting with odd or even rows.
🧠 Conceptual
advanced
1:30remaining
Accessibility in Data Tables
Which practice improves accessibility for screen reader users when using tables in Tailwind CSS?
AUse <code>div</code> elements with Tailwind classes instead of <code>table</code> elements
BAdd <code>aria-hidden="true"</code> to all table cells
CUse <code>border-collapse: separate</code> to separate cells visually
DAdd <code>scope="col"</code> to all <code>&lt;th&gt;</code> elements in the table header
Attempts:
2 left
šŸ’” Hint
Screen readers rely on semantic markup to understand table structure.
ā“ layout
advanced
2:30remaining
Fixed Header with Scrollable Table Body Using Tailwind CSS
Which option correctly creates a table with a fixed header and a scrollable body using Tailwind CSS?
A<div class="overflow-y-auto max-h-48"><table class="min-w-full border-collapse border border-gray-300"><thead class="sticky top-0 bg-white"><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td></tr><tr><td class="border border-gray-300 p-2">Carol</td><td class="border border-gray-300 p-2">28</td></tr></tbody></table></div>
B<table class="min-w-full border-collapse border border-gray-300"><thead class="fixed top-0 bg-white"><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th></tr></thead><tbody class="overflow-y-auto max-h-48"><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td></tr><tr><td class="border border-gray-300 p-2">Carol</td><td class="border border-gray-300 p-2">28</td></tr></tbody></table>
C<div class="overflow-y-scroll max-h-48"><table class="min-w-full border-collapse border border-gray-300"><thead class="sticky top-0 bg-gray-100"><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td></tr><tr><td class="border border-gray-300 p-2">Carol</td><td class="border border-gray-300 p-2">28</td></tr></tbody></table></div>
D<div class="overflow-auto max-h-48"><table class="min-w-full border-collapse border border-gray-300"><thead><tr><th class="border border-gray-300 p-2">Name</th><th class="border border-gray-300 p-2">Age</th></tr></thead><tbody><tr><td class="border border-gray-300 p-2">Alice</td><td class="border border-gray-300 p-2">30</td></tr><tr><td class="border border-gray-300 p-2">Bob</td><td class="border border-gray-300 p-2">25</td></tr><tr><td class="border border-gray-300 p-2">Carol</td><td class="border border-gray-300 p-2">28</td></tr></tbody></table></div>
Attempts:
2 left
šŸ’” Hint
Use a container with fixed height and overflow, and make the header sticky with top positioning.
šŸ“ Syntax
expert
2:30remaining
Tailwind CSS Class for Accessible Sortable Table Headers
You want to add an accessible sortable column header using Tailwind CSS. Which option correctly includes the necessary ARIA attribute and visual indicator?
A<th scope="col" aria-sort="ascending" class="cursor-pointer">Name <span aria-hidden="false">ā–²</span></th>
B<th scope="col" aria-sort="ascending" class="cursor-pointer select-none">Name <span aria-hidden="true">ā–²</span></th>
C<th scope="col" aria-sort="descending" class="cursor-default">Name <span aria-hidden="false">ā–¼</span></th>
D<th scope="col" aria-sort="true" class="cursor-pointer">Name <span>ā–²</span></th>
Attempts:
2 left
šŸ’” Hint
ARIA attribute aria-sort accepts specific values and visual indicators should be hidden from screen readers.