<tr>要素
Technical Summary
trはtableの1行を表し、行に属するtdとthを子として持ちます。行番号にはtable全体に対するrowIndexと、親要素のrows collectionに対するsectionRowIndexがあり、親要素は通常row groupですが、条件を満たすtableそのものの場合もあります。
table直下にtrを書いたHTMLは、parserが暗黙のtbodyを補ってDOMを作ります。これは書いたソースと構築されたDOMの差です。実装観測とWPT結果は、HTML-AAMに定めるrole mappingとは別のEvidenceとして記録します。
定義・配置条件・content model
| 項目 | 仕様上の定義 | 条件・範囲 |
|---|---|---|
| 意味 | table内のcell row | 各cellの意味はtdまたはthが示す |
| 配置先 | thead、tbody、tfootの子。または条件を満たす場合はtableの子 | tableにtbodyの子がないこと、既存要素との順序などの条件がある。HTML markupでは別の構文制約も適用される |
| content model | 0個以上のtd、th、script-supporting elements | 空の行もcontent model上は許される |
| content category | 特定のcategoryに分類されない | table model上のrowとして定義される |
| content attributes | Global attributes | tr固有のcontent attributeは定義されない |
| 終了タグ | 条件下で省略可能 | 次が別のtr、または親要素内に後続内容がない場合 |
| DOM interface | HTMLTableRowElement | 行の位置、cell collection、cellの挿入・削除を提供する |
HTML Standardのcontent modelは条件付きでtable直下のtrを扱いますが、HTML構文の適合性規則ではtableにtrを直接含めないよう定めています。ソースに直接書かれたtrは、parserがtbody開始タグを補う特別な処理を受けます。新しいmarkupではrow groupを明示すると、構造を読み取りやすくできます。
Row groupとparserのDOM構築
| 要素 | 役割 | 行との関係 |
|---|---|---|
thead | 表の見出し部分 | 子に見出し行を持つ |
tbody | 表の本体 | 複数のrow groupを分けて表せる |
tfoot | 表のまとめ部分 | 子にまとめの行を持つ |
<table>
<thead><tr><th>項目</th><th>値</th></tr></thead>
<tbody><tr><th>合計</th><td>3</td></tr></tbody>
</table>
このコードでは各trの親がrow groupです。rowspan="0"のcellは同じrow groupの残りの行をまたぐため、複数のtbodyを使う表ではgroup境界がtable modelに関係します。
HTMLTableRowElementと行API
| member | 戻り値・動作 | 範囲・境界 |
|---|---|---|
rowIndex | tableのrows collection内の位置 | 0始まり。tableに属さない場合は-1 |
sectionRowIndex | 親tableまたはrow groupのrows collection内の位置 | 0始まり。対応する親に属さない場合は-1 |
cells | 行の子であるtdとthのHTMLCollection | 子孫のnested tableにあるcellは含めない |
insertCell(index) | 新しいtdを作り、行に挿入する | 省略値は-1。範囲外indexはIndexSizeError |
deleteCell(index) | 指定位置のtdまたはthを削除する | -1は最後のcell。範囲外indexはIndexSizeError |
const row = document.querySelector("tbody tr");
row.rowIndex; // table全体に対する位置
row.sectionRowIndex; // 親tbodyに対する位置
row.cells; // この行のth・td
row.insertCell(-1); // 末尾にtdを追加
row.deleteCell(-1); // 末尾のcellを削除
rowIndexは視覚上の列位置でも、section内の番号でもありません。複数のrow groupがある場合はtable全体と親groupを区別し、行がtableの直接の子ならsectionRowIndexもtableのrowsを基準にします。また、insertCell()が作るのは常にtdです。
Accessibility role
HTML-AAMはtrの暗黙のroleをrowに対応付けます。実際のbrowser Accessibility treeでの露出、platform API上の値、支援技術が読み上げる文言は同一の測定ではありません。このTopicのImplementation Evidenceには、実測した環境と範囲だけを記録します。
Fact / Evidence(主張 / 根拠)
主要な仕様上の主張を適用条件と根拠位置に対応付けます。実装観測、WPT、Accessibility role queryは下のImplementation Evidenceに分けています。
| 種別 | Fact / 主張 | 条件・範囲 | 状態 | 根拠 |
|---|---|---|---|---|
| SPEC | trはtable内のcell rowで、子にtd・th・script-supporting elementsを持つ。 | 配置コンテキスト、content model、global attributes、終了タグを扱う場合。 | 仕様確認済み | HTML Standard: the tr element |
| SPEC | rowIndexとsectionRowIndexは異なるrows collectionに対する位置を返す。 | table全体、親row group、tableを直接の親とする行、table外の場合を区別する。 | 仕様確認済み | HTML Standard: the tr element |
| SPEC | cellsは行の直接のtd・thを返し、insertCell()はtdを作る。 | collectionの範囲、挿入位置、index範囲エラーを含む。 | 仕様確認済み | HTML Standard: the tr element |
| SPEC | HTML構文でtable内に直接書いたtrの前に、parserはtbody開始タグを補う。 | ソース上の表現と、構築後DOMの親子関係を分けて扱う。 | 仕様確認済み | HTML Standard: restrictions on content models |
| AAM | HTML-AAMはtrにrow roleを対応付ける。 | 仕様上のmappingと、特定browserのAccessibility tree観測を混同しない。 | 仕様確認済み | HTML-AAM: tr |
Evidence
- HTML Standard: The
trelement — meaning, context, content model, attributes, and row APIs - HTML Standard: The
tableelement — row groups and table child ordering - HTML Standard: Restrictions on content models — implied
tbodyfor atrwritten undertable - HTML Accessibility API Mappings:
tr— implicit row role and platform mappings - Web Platform Tests:
the-tr-element— row collection, indexing, and cell methods
Implementation Evidence
仕様上の要求と、選定環境でのbrowser観測、WPT実行、Accessibility role queryを分けて記録します。各結果は指定したfixture・browser・テスト範囲に限られます。
| 種別 | 再現確認の範囲 | 記録条件 | 状態 |
|---|---|---|---|
| IMPL | HTMLTableRowElement、cells、rowIndex、sectionRowIndex、table parserの暗黙tbody、insertCell() / deleteCell() |
2026-10-11 JST / Chrome UA 155.0.0.0(Windows NT 10.0 UA)/ viewport 1280×720 / navigator.language=ja。build-config/yugien/research-results/tr-v1/をloopback 127.0.0.1:4196で表示し、fixture checks 14/14 pass。直接のtd/thだけがcellsに含まれnested table内のcellは除外、rowIndexは表全体、sectionRowIndexはrow group内で数えること、直接書かれたtrの前にparserがtbodyを補うこと、detached rowのindexが-1になること、insert/deleteと境界外IndexSizeErrorを確認。1 browser環境のみ。OS buildと他browserは未測定。 |
部分観測(Chrome 155 / fixture 14/14) |
| WPT | trのcell collection、cell insertion/deletion、rowIndex、sectionRowIndexに関する選定WPT |
2026-10-11 JST / Chrome UA 155.0.0.0 / wpt.live。cells.html 1/1 pass、deleteCell.html 6/6 pass、insertCell.html 7/7 pass、rowIndex.html 12/12 pass、sectionRowIndex.html 19/19 pass。合計45/45 pass。wpt.liveが配信したupstream revisionは特定できないためwptRevisionは未記録。選定外WPTと他browserは未実施。再測定(2026-10-11): Chrome 154.0.8037.98 / Windows build 26300。このページに挙げたテストファイル5件を実行し、45項目が成功、0項目が失敗、0項目が時間切れ、0項目は未実行でした。詳細: docs/atlas/wpt-results-2026-10-11.md。このページに挙げたもの以外のテストと、他のブラウザーは未確認です。 このSHAは2026-10-11の再測定だけに当てはまります。以前の実行版は未記録です。実行したテストの版: |
一部のテストだけ実行(テスト版を記録) |
| AAM | Chromeのbrowser role queryによるnative table、row group、row、column header、data cellの公開 | 2026-10-11 JST / Chrome UA 155.0.0.0(Windows NT 10.0 UA)/ viewport 1280×720 / navigator.language=ja。fixtureのnamed table Fruit prices todayをqueryし、table 1、row 5、row group 4、column header 2、row header 0、data cell 8を確認。row nameはFruit / Price、Apples / $1.20、Pears / $1.45、Oranges / $0.80、Items / 3。これはbrowser role queryによる観測であり、HTML-AAMの全mapping、Windows UIAなどのplatform API、スクリーンリーダーの発話は未測定。 |
部分観測(Chrome 155 browser role query / 1環境) |
ブラウザーのrole・name queryはplatform Accessibility APIやスクリーンリーダーの発話と同じ測定ではありません。実施した層と未測定の範囲を分けて扱います。
Coverage / Open Issues
- 確認済み要素の意味・配置・content model、row group、HTMLTableRowElementの主要member、HTML-AAM role mapping
- 未完了実装観測は選定fixtureとbrowser 1環境に限る。複数table・section境界・detached rowの全分岐は未網羅
- 未完了選定WPT以外、他browser engine、固定したWPT revisionでの結果
- 未完了platform Accessibility API、Windows UI Automation、支援技術の読み上げ、他OS、Expert-gap Review
このTopicは初期Coverageです。選定した測定の成功は、すべてのHTML構造、browser、OS、支援技術で同じ結果になることを示しません。
関連Surface
初心者向けの行の例はYugienのtr要素ページ、行をまとめる表本体はYugienのtbody要素ページ、表のまとめの行はYugienのtfoot要素ページを参照してください。表全体のmodelはtable Topic、行グループの仕様とAPIはtbody Topicとtfoot Topic、見出しセルはth Topic、データセルはtd Topic、表題はcaption Topicで扱います。