Anatomy of a React component
My vision for how every React component should look
421
8 min.
The SST standard defines requirements for the semantics, accessibility, and logic of tables.
<caption>. If present, <caption> is the first element inside <table>. A caption helps explain the table's purpose, but does not by itself guarantee an SEO improvement.<thead> groups rows containing column headings. A browser or document generator may repeat this group in paged print; actual behavior depends on the print engine and page-break settings.<tbody> elements group data rows. Multiple <tbody> groups are used when rows are divided into logical sections. A table has no more than one <thead> and one <tfoot> section.<tfoot> contains summary or total rows. Under the current HTML model, it is placed after the table's row groups; CSS displays it as the table footer group. Older examples that place <tfoot> before <tbody> should not be treated as current markup guidance.<tr> defines a row, <th> a header cell, and <td> a data cell. <th> and <td> must reflect the actual role of the content, not just the desired visual style.<colgroup> represents a group of columns and is placed after <caption> and before the row groups.<col> describes one or more columns within <colgroup>. Its span attribute specifies the number of columns covered by the element.<colgroup> contains <col> elements, the number of columns is specified with span on <col>. Alternatively, span can be set directly on an empty <colgroup> with no child <col> elements.<col> and <colgroup> are useful for setting column widths and backgrounds. The CSS properties that apply to them are limited; for example, text-align and padding on <col> do not align text or set cell padding.<th> or <td> has an opaque background, the <col> color may not be visible. Column borders set through <col> are displayed only with collapsed borders.<th scope="col">, and a row heading uses <th scope="row">. The scope attribute associates a header cell with the data it applies to.scope="rowgroup" and scope="colgroup" when the table structure matches those groups.scope alone may not be sufficient. Explicitly associate headers and data cells with unique id values on <th> and corresponding headers values on <td>.Example of simple row and column headers:
<table>
<caption>Project participants</caption>
<thead>
<tr>
<th scope="col">Field</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">User name</th>
<td>Alex</td>
</tr>
</tbody>
</table><th> and <td> cells. padding on a <tr> row does not control the padding of its cells.border-collapse: collapse combines adjacent cell borders into a shared grid. With border-collapse: separate, borders and the spacing between them are handled separately.empty-cells: show and empty-cells: hide control the display of borders and backgrounds on empty cells only with border-collapse: separate. The property does not remove a cell from the table or define the meaning of missing data.<table>, <tr>, <th>, and <td> retain their native table display model when the content genuinely represents rows and columns.display to flex or grid changes the layout algorithm: the cells in that row no longer participate in the shared table grid, so columns may no longer align across rows.text-align: start and text-align: end instead of unconditional left and right.table-layout: fixed is suitable when column widths need to be distributed more predictably and the table itself has a specified width other than auto.<col>, then by widths on cells in the first row; any remaining space is distributed among the other columns.overflow-x: auto. The container width must be constrained by its parent area.<table> element retains its native table display. display: block is not used as a substitute for an overflow container: changing the display type can disrupt row layout and shared column alignment.-webkit-overflow-scrolling: touch is not a baseline requirement for accelerated scrolling on iOS and iPadOS 13 or later. On iPhone, the property can create a stacking context; retain it only when it is demonstrably needed for older target systems and after checking for side effects.Example of a scrollable container:
<div
class="table-scroll"
role="region"
aria-label="Monthly sales summary"
tabindex="0"
>
<table class="data-table data-table--wide">
<caption>Monthly sales summary</caption>
<colgroup>
<col class="data-table__month">
<col span="2" class="data-table__metrics">
</colgroup>
<thead>
<tr>
<th scope="col">Month</th>
<th scope="col">Orders</th>
<th scope="col">Revenue</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">January</th>
<td>120</td>
<td>360,000 ₽</td>
</tr>
<tr>
<th scope="row">February</th>
<td>145</td>
<td>435,000 ₽</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row">Total</th>
<td>265</td>
<td>795,000 ₽</td>
</tr>
</tfoot>
</table>
</div>.table-scroll {
max-width: 100%;
overflow-x: auto;
}
.data-table {
width: 100%;
border-collapse: collapse;
}
.data-table--fixed {
table-layout: fixed;
}
.data-table--separate {
border-collapse: separate;
empty-cells: hide;
}
.data-table--wide {
min-width: 42rem;
}
.data-table__month {
width: 40%;
}
.data-table__metrics {
background-color: #f5f5f5;
}
.data-table th,
.data-table td {
padding: 0.75rem;
border: 1px solid #ccc;
}
.data-table th {
text-align: start;
}
.data-table td {
text-align: end;
}
.table-scroll:focus-visible {
outline: 2px solid currentColor;
outline-offset: 2px;
}The data-table--wide class is used only when columns need a defined minimum width; the 42rem value is adjusted to the content. A background set through <col> remains visible unless it is covered by a cell or row background.
position: sticky to <th> cells inside <thead>.z-index; otherwise, row content may show through or overlap the headings.position: sticky is constrained by the nearest scroll container. When a sticky header is combined with a horizontally scrollable area, test behavior both during page scrolling and inside the container.Example of sticky headings:
.data-table thead th {
position: sticky;
top: 0;
z-index: 1;
background-color: #fff;
}<thead> retains the semantic header group. Print and PDF engines may repeat it when a long table spans multiple pages; verify the result in the target print environment.caption, colgroup, thead, tbody groups, and tfoot.scope or id/headers relationships with a screen reader.<tbody> groups, spanning cells, and multi-level headings when those cases are used.table-layout: fixed, as well as focus and sticky-header layering when used.border-collapse value; empty values must not change the meaning of the data.My vision for how every React component should look
421
8 min.
The SST standard defines requirements for the semantics, accessibility, and logic of tabs
62
7 min.
The SSF-U standard defines requirements for the semantics, accessibility, and logic of fullscreen
248
2 min.
The SSA standard defines requirements for the semantics, accessibility, and logic of accordion
258
2 min.
An Analysis of Critical Web Design Mistakes. Why Sliders, Autoplay, and Slow-Loading Pages Reduce Conversion Rates and Rankings on Google
232
2 min.
The SSP standard defines requirements for the semantics, accessibility, and logic of pagination
240
1 min.