gpt4 book ai didi

html -
元素可以只包含
而没有图像吗?

转载 作者:太空狗 更新时间:2023-10-29 13:23:08 24 4
gpt4 key购买 nike

它是 <figure> 的语义吗?元素只包含一个 <figcaption> ?它确实 validate ...

<figure>
<img src="example.jpg">
<figcaption>Image and caption</figcaption>
</figure>

<figure>
<figcaption>Caption only</figcaption>
</figure>

在这种情况下,它会对 CSS 样式产生影响:

figure figcaption { color: red; }

最佳答案

imgfigure 中不需要元素,它恰好很常见,并且大多数使用 figcaption 的示例还有一张图片。

http://dev.w3.org/html5/spec/single-page.html#the-figure-element

The <figure> element can thus be used to annotate illustrations, diagrams, photos, code listings, etc, that are referred to from the main content of the document, but that could, without affecting the flow of the document, be moved away from that primary content, e.g. to the side of the page, to dedicated pages, or to an appendix.

http://dev.w3.org/html5/spec/single-page.html#the-figcaption-element

The <figcaption> element represents a caption or legend for the rest of the contents of the figcaption element's parent figure element, if any.

请注意“if any”部分,这让我相信 figcaption 以外的内容可能不存在,但仍然有效。但是,正如 Alochi 指出的那样,这表明该元素被滥用,因为标题没有要描述的内容。

在当前规范示例中有一个非图像内容伴随着图形说明的示例,因此我认为可以公平地假设没有图像是完全可以的:

Here, a part of a poem is marked up using figure.

<figure>
<p>'Twas brillig, and the slithy toves<br>
Did gyre and gimble in the wabe;<br>
All mimsy were the borogoves,<br>
And the mome raths outgrabe.</p>
<figcaption>
<cite>Jabberwocky</cite> (first verse).
Lewis Carroll, 1832-> 98
</figcaption>
</figure>

关于html - <figure> 元素可以只包含 <figcaption> 而没有图像吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13729232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com