图形标记是否可以包含包装图像的锚标记?

时间:2015-02-23 08:49:57

标签: html html5 figure

我正在尝试创建一个包含图像的锚标记内的图形标记。我想知道这种结构是否合法。以下代码显示了我希望它如何工作。

<figure>
   <a href="/my-picture">
       <img src="img/picture.jpg" alt="My picture">
   </a>
   <figcaption>
       My picture
   </figcaption>
</figure>

1 个答案:

答案 0 :(得分:9)

验证员说它的结构是正确的,所以是的。

说到语义我没有看到任何问题,但是请记住,在HTML5中你可以将整个图形包装在一个可能有用的链接中,因为在大多数情况下你也要包装描述。

我用它来验证:

<!DOCTYPE html>
<html>
  <head>
    <title>a</title>
  </head>
  <body>
    <figure>
      <a href="/my-picture">
        <img src="img/picture.jpg" alt="My picture">
      </a>
      <figcaption>
        My picture
      </figcaption>
    </figure>
  </body>
</html>