描述
當您有一個非常大的表格或故意只想顯示錶格的一部分時,並非所有列都可能存在於 DOM 中。在這種情況下,我們使用具有整數值的 aria-colcount 來定義如果所有列都存在,表格(或網格)將有多少列,並在每列上新增 aria-colindex 屬性,以提供有關該較大資料列索引的資訊。
在以下 HTML 程式碼片段中,我們的表格有 8 列,但我們只顯示了 4 列。“city”列是我們較大表格的第五列,由 aria-colindex="5" 定義。
<table aria-colcount="8">
<thead>
<tr>
<th aria-colindex="1" scope="col">First name</th>
<th aria-colindex="2" scope="col">Last name</th>
<th aria-colindex="5" scope="col">City</th>
<th aria-colindex="7" scope="col">Zip</th>
</tr>
</thead>
…
</table>
這個表格並不複雜。如果這是一個擁有 100 多列的電子表格或一個沒有列標題的網格,例如棋盤,那麼提供的或計算的 aria-colindex 值可能沒有意義,或者可能無法反映顯示的索引。在這種情況下,可以包含 aria-colindextext。該值是一個字串,是對數字 aria-colindex 的人類可讀文字替代。
<table aria-colcount="128">
<thead>
<tr>
<th aria-colindex="1" aria-colindextext="NYSE stock symbol" scope="col">
NYSE
</th>
<th
aria-colindex="110"
aria-colindextext="Value at start of 2021"
scope="col">
01/21
</th>
<th
aria-colindex="122"
aria-colindextext="Value at start of 2022"
scope="col">
01/22
</th>
<th aria-colindex="124" scope="col">Recommendation</th>
</tr>
</thead>
…
</table>
在上面的示例中,表格有 128 列,其中只顯示了 4 列。aria-colindextext 在三列中使用,以提供人類可讀的文字替代。透過包含 aria-colindextext="Value at start of 2021",輔助技術可以播報“Value at start of 2021”(2021 年初的值),而不是“Column 110”(第 110 列)。
只有當提供的或計算的 aria-colindex 值沒有意義或未反映顯示的索引時,才使用 aria-colindextext。每當包含 aria-colindextext 時,也要保留 aria-colindex,因為某些輔助技術依賴數字列索引來跟蹤使用者位置和提供替代表格導航。
注意:雖然 aria-colindex 可以新增到行中(當所有存在的列都是連續的,可以推斷出順序值時),但 aria-colindextext 不是 row 的支援屬性。
請參閱相關的 aria-rowindextext。
值
<string>-
數字
aria-colindex的人類可讀文字替代。
相關介面
Element.ariaColIndexText-
Element介面的一部分ariaColIndexText屬性反映了aria-colindextext屬性的值。 ElementInternals.ariaColIndexText-
ElementInternals介面的一部分ariaColIndexText屬性反映了aria-colindextext屬性的值。
相關角色
用於角色
繼承至角色
規範
| 規範 |
|---|
| 無障礙富網際網路應用程式 (WAI-ARIA) # aria-colindextext |