pub struct Td;Expand description
The <td> element - defines a data cell in a table.
§Purpose
The <td> element represents a data cell in a table. It contains the actual data values
within table rows. Can span multiple rows or columns using rowspan and colspan attributes.
Distinguished from <th> header cells which label data.
§Content Categories
- Sectioning Root
§Permitted Content Model
- Flow content
§Common Use Cases
- Displaying data values in tables
- Creating spreadsheet cells
- Showing individual records in datasets
- Building data grids and matrices
- Presenting structured information
§Key Attributes
colspan: Number of columns the cell spansrowspan: Number of rows the cell spansheaders: Space-separated list of header cell IDs this cell relates to
§Example
<!-- Basic data cells -->
<table>
<tr>
<th>Name</th>
<th>Score</th>
</tr>
<tr>
<td>Alice</td>
<td>95</td>
</tr>
<tr>
<td>Bob</td>
<td>87</td>
</tr>
</table>
<!-- Cells with colspan -->
<table>
<tr>
<td colspan="2">This cell spans two columns</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
<!-- Cells with rowspan -->
<table>
<tr>
<td rowspan="2">Spans 2 rows</td>
<td>Row 1, Col 2</td>
</tr>
<tr>
<td>Row 2, Col 2</td>
</tr>
</table>
<!-- Complex table with headers attribute -->
<table>
<thead>
<tr>
<th id="name">Name</th>
<th id="math">Math</th>
<th id="science">Science</th>
</tr>
</thead>
<tbody>
<tr>
<th id="alice">Alice</th>
<td headers="alice math">95</td>
<td headers="alice science">92</td>
</tr>
</tbody>
</table>
<!-- Rich content in cells -->
<table>
<tr>
<td>
<strong>Product Name</strong><br>
<small>SKU: 12345</small>
</td>
<td>
<a href="/details">View Details</a>
</td>
</tr>
</table>§Accessibility
- Use
headersattribute to associate cells with headers in complex tables - Ensure data cells are properly associated with their headers
- Keep cell content concise and scannable
- Use
scopeon header cells to clarify relationships
§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Td
impl HtmlElement for Td
impl<T: FlowContent> CanContain<T> for Td
impl CanContain<Td> for Tr
impl CanContain<Text> for Td
Auto Trait Implementations§
impl Freeze for Td
impl RefUnwindSafe for Td
impl Send for Td
impl Sync for Td
impl Unpin for Td
impl UnwindSafe for Td
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more