gpt4 book ai didi

html - caption(table) 和 legend(fieldset) 是唯一的 html first descendant 限制吗?

转载 作者:可可西里 更新时间:2023-11-01 13:28:50 25 4
gpt4 key购买 nike

<legend>, if used, must immediately follow <fieldset>
<caption>, if used, must immediately follow <table>

HTML 中还有其他类似“必须是第一个后代”的限制吗?(在没有阅读每个标签的完整规则的情况下,您是否可以在某个地方找到此类信息?) [主要关心 html5]

最佳答案

您可以在其他地方使用它们,但例如。 legend 为 Fieldset 上的标题提供了独特的样式,如果您错过了它,它将无法正常工作同样 caption 对表格有一些特定的含义。

这些只是预定义的标准。

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 80%;
margin: 0 auto;
}
legend {
padding: 2px;
color: purple
}
fieldset {
margin-bottom: 10px;
padding: 5px 10px;
border: 2px solid #000;
}
input {
width: 100%;
padding: 5px 15px;
}
<div class="container">
<fieldset>
<legend>Heading inside Legend</legend>
<input type="text">
</fieldset>

<table border="1" cellspacing="0" style="width:100%;">
<caption>Caption inside Table</caption>
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
<tr>
<td>b</td>
<td>b</td>
<td>b</td>
<td>c</td>
<td>d</td>
</tr>
</table>
</div>

关于html - caption(table) 和 legend(fieldset) 是唯一的 html first descendant 限制吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33238713/

25 4 0