html figure元素:figcaption可以放在img之前吗

html figure element: can figcaption be placed before img

semantically/syntactically 将 figcaption 元素放置在 figure 元素内的任何位置是否正确?

考虑以下几点:

<figure>
  <figcaption>Hello caption</figcaption>
  <img src="/path/to/file">
</figure>

tl;博士:

  • W3C:figcaption 可以放在 figure 中的任何位置(作为 child,不是后代)
  • WHATWG:figcaption 可以放在 figure
  • 的第一个或最后一个 child

W3C

In HTML5figcaption 元素必须是 figure 的第一个或最后一个 child:

Either: One figcaption element followed by flow content.
Or: Flow content followed by one figcaption element.
Or: Flow content.

In HTML 5.1figcaption元素可以放在figure元素的任意位置:

Flow content optionally including a figcaption child element.

In HTML 5.1 2nd Edition,也是。

In HTML 5.2 (Proposed REC),也是

这里是关于更改的问题:
Allow figcaption anywhere in a figure element?

WHATWG

In the HTML Living Standard(截至 2017-11-17),与 HTML5:

相同

Either: One figcaption element followed by flow content.
Or: Flow content followed by one figcaption element.
Or: Flow content.