问题描述
为什么错了?
<table>
<form>
<tr><td>something something</td/>
</form>
</table>
我说的是表格标签在表格标签中的位置.
I'm talking about position of form tags inside table tags.
推荐答案
来自 DTD :
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
<!ELEMENT CAPTION - - (%inline;)* -- table caption -->
<!ELEMENT THEAD - O (TR)+ -- table header -->
<!ELEMENT TFOOT - O (TR)+ -- table footer -->
<!ELEMENT TBODY O O (TR)+ -- table body -->
<!ELEMENT COLGROUP - O (COL)* -- table column group -->
<!ELEMENT COL - O EMPTY -- table column -->
<!ELEMENT TR - O (TH|TD)+ -- table row -->
<!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell-->
这些是您可以在table
元素内拥有的唯一元素(在本例中为HTML 4,但是您检查了相同类型的文档的其他版本,并且更改不多).
These are the only elements you can have inside a table
element (in HTML 4 in this case, but you check the same kind of document for other versions, and it's not changed much).
另一方面,form
元素可以包含任何其他块级元素(其他形式除外):
On the other hand, a form
element can contain any other block-level element (except other forms):
<!ELEMENT FORM - - (%block;|SCRIPT)+ -(FORM) -- interactive form -->
td
元素可以包含任何"flow"元素(如第一个代码块所示),并且"flow"包括块级元素:
And the td
element can contain any "flow" element (as seen in the first code block), and "flow" include block level elements:
<!ENTITY % flow "%block; | %inline;">
因此,您可以将<form>
标签放在整个表格周围或一个表格单元格内.
So you can put your <form>
tags either around the entire table or inside one table cell.
这篇关于表内表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!