メニュー

表

行と列で数字を見比べる部品です。数字は右揃え・等幅の数字にし、単位は見出しに書きます。

見本で種類と状態を確かめる

行の高さは 48、縞は付けません。見出しは label の文字で下に line-strong、合計の行は太字にせず上に line-strong を引きます。横にはみ出す表は包みの中でスクロールし、続きのある側の端にだけ薄い影が出ます。

選択の行と合計

月ごとに貯金は増えているか
期間収入(円)支出(円)収支(円)
2026年9月298,540311,870−13,330
2026年10月301,200287,45013,750
2026年11月286,000238,34047,660
3か月の合計885,740837,66048,080

横にスクロール

費目ごとの支出は月でどう動いたか(円)
費目5月6月7月8月9月10月11月
食費48,21051,38046,92049,87047,65050,24045,310
日用品8,4206,1309,8707,2406,9808,1507,560
交通11,2009,86012,40010,75011,98010,3209,640

コードを写す

HTML

<div class="mz-table-wrap" data-sp="list" role="region" aria-labelledby="cap-light" tabindex="0">
  <table class="mz-table">
    <caption id="cap-light">月ごとに貯金は増えているか</caption>
    <thead>
      <tr>
        <th scope="col" aria-sort="ascending"><button class="mz-table__sort" type="button"><span>期間</span><svg class="mz-table__sort-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 19V5"/><path d="m5 12 7-7 7 7"/></svg></button></th>
        <th scope="col" data-numeric><button class="mz-table__sort" type="button"><span>収入(円)</span><svg class="mz-table__sort-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg></button></th>
        <th scope="col" data-numeric><button class="mz-table__sort" type="button"><span>支出(円)</span><svg class="mz-table__sort-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m7 15 5 5 5-5"/><path d="m7 9 5-5 5 5"/></svg></button></th>
        <th scope="col" data-numeric>収支(円)</th>
        <th scope="col" data-numeric>貯金の残高(円)</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row"><a href="/months/2026-08">2026年8月</a></th>
        <td data-numeric>412,300</td>
        <td data-numeric>356,120</td>
        <td data-numeric>56,180</td>
        <td data-numeric>2,184,600</td>
      </tr>
      <tr>
        <th scope="row"><a href="/months/2026-09">2026年9月</a></th>
        <td data-numeric>298,540</td>
        <td data-numeric>311,870</td>
        <td data-numeric data-tone="danger">−13,330</td>
        <td data-numeric>2,171,270</td>
      </tr>
      <tr>
        <th scope="row"><a href="/months/2026-10">2026年10月</a></th>
        <td data-numeric>301,200</td>
        <td data-numeric>287,450</td>
        <td data-numeric>13,750</td>
        <td data-numeric>2,185,020</td>
      </tr>
      <tr aria-current="true">
        <th scope="row"><a href="/months/2026-11">2026年11月</a></th>
        <td data-numeric>286,000</td>
        <td data-numeric>238,340</td>
        <td data-numeric>47,660</td>
        <td data-numeric>2,232,680</td>
      </tr>
    </tbody>
    <tfoot>
      <tr>
        <th scope="row">4か月の合計</th>
        <td data-numeric>1,298,040</td>
        <td data-numeric>1,193,780</td>
        <td data-numeric>104,260</td>
        <td data-numeric>—</td>
      </tr>
    </tfoot>
  </table>
</div>

見出しで並べ替えるときは、<th aria-sort> の中に <button class="mz-table__sort"> を置きます。全体の見本は demo/table.html にあります。

いつ使うか

  • 月ごと・費目ごとなど、行と列の両方で数字を見比べるときに使います。行を見るだけなら一覧にします。
  • 単位は見出しに書き、セルは数字だけにします。
  • 640 未満の幅で列が 4 つを超える表は、一覧に組み替えた版を用意します。包みに data-sp="list" を付けると 640 未満で隠れ、data-table-sp を付けた一覧がそのときだけ出ます。

読み上げとキーボードにどう応えるか

  • <caption> に見える見出しを書きます。包みは role="region" と aria-labelledby で caption と結び、tabindex="0" でキーボードから横にスクロールできるようにします。
  • 列の見出しは scope="col"、行の見出しは scope="row" にします。
  • スクロールバーは隠しません。

よい例と悪い例

固定費(円)
家賃78,000
通信6,480
よい例単位は見出しに書き、数字は右にそろえる
固定費
家賃78,000円
通信6,480円
悪い例セルごとに単位を付け左にそろえると、桁が縦にそろわず比べにくい

更新日

ページの一覧

索引を読み込んでいます。

メニュー