HTML figure

HTML figure

figure 和 figcaption 元素

figure标签规定独立的流内容(图像、图表、照片、代码等等)。

figure元素的内容应该与主内容相关,同时元素的位置相对于主内容是独立的。如果被删除,则不应对文档流产生影响。

figcaption元素被用来为figure元素定义标题。

例子

你可以在下面的代码中看到一起使用的 figure figcaption 元素。


<!DOCTYPE HTML>
<html>
<body>
  I like XML and CSS.
  <figure>
    <figcaption>Listing 01. Using the code element</figcaption>
    <code>
      var fruits = ["CSS", "HTML", "CSS", "Javascript"];<br>
      document.writeln("I like " + fruits.length + " fruits");
    </code>
  </figure>
</body>
</html>

上面的代码渲染如下:






0.0740s