我读了这个问题:Do I still need to use the title attribute if my element has a `<figcaption>`?
但答案是面向img
标签,但是,如果我有以下 figure
,没有img
,但带有 table
:
<figure title="The table of life">
<table>
<caption>The table of life</caption>
<tbody>...</tbody>
</table>
<figcaption>The table of life<figcaption>
</figure>
这里我有 3 种提供标题的方法:<caption>
标签(仅适用于 table
), <figcaption>
标签(仅适用于 figure
)和 title
属性(通用)。
哪个更好用?
这是 figure
的示例没有table
:
<figure title="Description of my char in RPG">
<h1>Seninha</h1>
<p>Seninha was born in the moon in the year of 13...<p>
<dl>
<dt>HP</dt><dd>15</dd>
<dt>MP</dt><dd>18</dd>
<dt>IQ</dt><dd>99999</dd>
<dt>ST</dt><dd>-10</dd>
</dl>
<figcaption>Description of my char in RPG<figcaption>
</figure>
最佳答案
caption
仅作为 table
的子项有效。 The MDN docs for caption
note :
Usage note: When the
<table>
element that is the parent of this<caption>
is the only descendant of a<figure>
element, use the<figcaption>
element instead.
我会省略 title
属性,因为它没有任何贡献。
关于html - HTML5 的 <figure> 标签中使用哪个标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23851404/