Error: Element a not allowed as child of element figure in this
context. (Suppressing further errors from this subtree.)
这是我在 html 文档正文中编写的代码:
<p>
<figure>
<img src="http://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="google"/>
<figcaption>Google</figcaption>
<a href="#"> A link. Is it allowed?</a>
</figure>
</p>
The HTML element represents a caption or a legend associated with a figure or an illustration described by the rest of the data of the element which is its immediate ancestor
这意味着 <figcaption> 元素必须是 <figure> 元素下的第一个或最后一个元素。
由于 <figcaption> 不是第一个元素(上面有图像)或最后一个元素(我将 <a> 元素放在它下面),我违反了这条规则。虽然您的浏览器布局不会因为这个小问题而中断,但您的网站将无法通过 w3.org 的 HTML 验证程序,因为它不符合适当的标准。