是否有预编码的标题?

时间:2017-09-06 11:37:04

标签: html html5 semantic-markup

表格有<caption>,数字有<figcaption>,但前面的正确标记是什么?

(目的是为listing设置标题,但似乎<listing>已删除,因此会使用<pre>。)

1 个答案:

答案 0 :(得分:2)

数字可以描绘代码清单,因此只需将<pre>放在<figure>内,然后使用<figcaption>作为标题。 spec包含一个完整的例子:

  

此示例显示标记代码列表的figure元素。

<p>In <a href="#l4">listing 4</a> we see the primary core interface
API declaration.</p>
<figure id="l4">
 <figcaption>Listing 4. The primary core interface API declaration.</figcaption>
 <pre><code>interface PrimaryCore {
 boolean verifyDataLine();
 void sendData(in sequence&lt;byte> data);
 void initSelfDestruct();
}</code></pre>
</figure>
<p>The API is designed to use UTF-8.</p>