假设我有这个,
<article>
<header>
<h1>Article title</h1>
<p>Article kicker</p>
<figure>
<img class="featured-image" src="http://article.com/featured/image.jpg">
</figure>
</header>
<div class="content">
<p>Bla bla</p>
<p>Bla bla</p>
</div>
<footer>
<p>About author</p>
</footer>
</article>
将 <figure>
放在语义上是否正确里面<header>
?
规范定义 <figure>
作为,
a unit of content, optionally with a caption, that is self-contained, that is typically referenced as a single unit from the main flow of the document
如果放在<header>
里面这会使<figure>
属于<article>
的头而不是属于<article>
本身?尝试环顾四周,但没有找到答案。
最佳答案
该图仍将是文章的一部分。它恰好位于文章标题中,如果您的图形实际上是文章标题的一部分而不是文章的主要内容,那就没问题。
如果您询问分段,<header>
和<footer>
不是剖面元素,因此该图仍将是文章大纲的一部分。即删除或注释掉 <header>
和<footer>
标签:
<article>
<!-- header -->
<h1>Article title</h1>
<p>Article kicker</p>
<figure>
<img class="featured-image" src="http://article.com/featured/image.jpg">
</figure>
<!-- /header -->
<div class="content">
<p>Bla bla</p>
<p>Bla bla</p>
</div>
<!-- footer -->
<p>About author</p>
<!-- /footer -->
</article>
结果相同。
关于html - 在<article>中,<figure>在语义上可以放在<header>中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41326740/