Option A uses overflow-x-auto on a wrapping div, which enables horizontal scrolling if the table is wider than the viewport. The table uses min-w-full to ensure it can grow beyond the container width if needed. This is the recommended pattern for responsive tables with Tailwind CSS.
Option A incorrectly applies overflow-x-auto directly on the table, which does not work as expected because tables do not scroll horizontally themselves.
Option A uses overflow-auto which allows vertical and horizontal scrolling, but w-full forces the table to fit container width, preventing horizontal scroll.
Option A uses overflow-x-scroll which forces a scrollbar always visible, which is less user-friendly than overflow-x-auto.
Option C is correct because Tailwind provides odd: and even: variants that apply styles to odd or even child elements respectively. Applying odd:bg-gray-100 on each <tr> colors every odd row with a light gray background, creating zebra striping.
Option C is incorrect because even:bg-gray-100 on <tbody> does not affect child rows individually.
Options C and D apply styles only to the first or last row, which is not zebra striping.
Option D is correct because adding scope="col" to <th> elements helps screen readers identify column headers, improving navigation and understanding of table data.
Option D is incorrect because replacing semantic table elements with divs removes important semantic meaning, harming accessibility.
Option D hides table cells from screen readers, which is harmful.
Option D affects visual style only and does not improve accessibility.
Option A correctly wraps the table in a div with overflow-y-auto and a max height to enable vertical scrolling. The <thead> uses sticky top-0 and a background color to fix the header at the top while scrolling.
Option A incorrectly applies fixed to <thead> and overflow to <tbody>, which does not work as expected.
Option A is close but uses overflow-y-scroll which always shows scrollbar and a different background color, less ideal.
Option A does not make the header sticky, so it scrolls away.
aria-sort accepts specific values and visual indicators should be hidden from screen readers.Option B is correct because aria-sort="ascending" is a valid ARIA attribute value indicating the column is sorted ascending. The span with the arrow uses aria-hidden="true" so screen readers ignore the visual arrow, avoiding redundancy.
Option B uses invalid aria-sort="true" which is not a valid value.
Option B uses aria-hidden="false" on the arrow, which exposes the arrow to screen readers unnecessarily, and cursor-default does not indicate interactivity.
Option B exposes the arrow to screen readers with aria-hidden="false", which is not recommended.