Proper heading for a table

前端 未结 3 1353
青春惊慌失措
青春惊慌失措 2021-01-21 00:35

A matter of semantics. If I have a HTML page that is basically one big table, what element do I use for a header?

Ordinarily, you\'d use a h1 for the headi

3条回答
  •  半阙折子戏
    2021-01-21 01:13

    I think one concern should always be how it ends up getting presented to screen-reader users.

    It seems that the caption element gets exposed by some platform accessibility APIs in a special way (e.g., in the IAccessible2 API as IA2_ROLE_CAPTION with a IA2_RELATION_LABEL_FOR) but not in all of them (for example, Apple’s AX API doesn’t seem to do anything so special with it).

    In comparison, I think h1 and all other headings always get exposed with a heading role. And screen readers consistently expose all headings in a way to facilitate navigation within documents.

    So I think maybe for screen-reader users, between caption and h1: In the context the question describes, if a document’s going to have one and not the other, it’s probably best that it be the h1.

提交回复
热议问题