[英]<tr> inside <td> not displayed properly
Can anybody tell me why my internal rows are not coming inside the td. 谁能告诉我为什么我的内部行不在td内部。
<tr id="group_1_id">
<th>Group 1</th>
<td>
<tr id="1"><td>1</td><td>One</td><td><input type="text" name="one" value="one"/></td></tr>
<tr id="2"><td>2</td><td>Two</td><td><input type="text" name="two" value="two"/></td></tr>
<tr id="3"><td>3</td><td>Three</td><td><input type="text" name="three" value="three"/></td></tr>
</td>
</tr>
The 3 table rows comes outside the parent tr. 表的3行位于父tr之外。 Though they are defined inside the td of my parent tr.
虽然它们是在我父母tr的td中定义的。
Thanks in advance 提前致谢
I would say that your HTML is not correct. 我会说您的HTML不正确。 If you want a header section, then use
<thead>
or <tbody>
element, not <th>
. 如果需要标题部分,请使用
<thead>
或<tbody>
元素,而不要使用<th>
。 I believe your problems emerged from the fact that you have used <th>
instead of <thead>
. 我相信您的问题来自于您使用
<th>
而不是<thead>
的事实。
You may want to use a validator to check whether your HTML is correct. 您可能需要使用验证器来检查您的HTML是否正确。 Upload your page to http://validator.w3.org for example, and correct the errors it shows you.
例如,将页面上传到http://validator.w3.org ,并更正显示的错误。
Also check the specification (for example on www.whatwg.org ) because I suppose that you wanted to create more than one header section in a table. 还要检查规范(例如,在www.whatwg.org上 ),因为我想您想在一个表中创建多个标题部分。 A table may have not more than one
<thead>
, not more than one <tfoot>
, and any number of <tbody>
elements. 一个表可能不超过一个
<thead>
,不超过一个<tfoot>
和任意数量的<tbody>
元素。
Oh, you have just reedited the question, but the problem is the same :) 哦,您刚刚编辑了问题,但是问题是相同的:)
A <tr>
element cannot be placed inside a <td>
or <th>
. <tr>
元素不能放在<td>
或<th>
。 When that code is parsed, a nested table is automagically created, so the real HTML looks like this: 解析该代码后,将自动创建一个嵌套表,因此实际的HTML如下所示:
<tr id="group_1_id">
<th>Group 1</th>
<td>
<table>
<tbody>
<tr id="1"><td>1</td><td>One</td><td><input type="text" name="one" value="one"/></td></tr>
<tr id="2"><td>2</td><td>Two</td><td><input type="text" name="two" value="two"/></td></tr>
<tr id="3"><td>3</td><td>Three</td><td><input type="text" name="three" value="three"/></td></tr>
</tbody>
</table>
</td>
</tr>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.