问题
The following w3c
documents mentions rowgroup
- http://www.w3.org/TR/html401/struct/tables.html#h-11.2.6
- http://www.w3.org/TR/html401/struct/tables.html#rowgroups
<!ENTITY % Scope "(row|col|rowgroup|colgroup)">
Is there such an attribute or property?
回答1:
No, there is no such element. If you want to group rows, you can put the particular tr
elements in the same class.
The “rowgroup” you are referring to is a row group that is naturally formed by an element like thead
, tbody
and tfoot
. And Scope is used to define the value set in the same-named attribute scope that is used to refer to the scope the current th
element is providing information for:
<!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell--> <!-- Scope is simpler than headers attribute for common tables --> <!ENTITY % Scope "(row|col|rowgroup|colgroup)"> <!-- TH is for headers, TD for data, but for cells acting as both use TD --> <!ATTLIST (TH|TD) -- header or data cell -- %attrs; -- %coreattrs, %i18n, %events -- abbr %Text; #IMPLIED -- abbreviation for header cell -- axis CDATA #IMPLIED -- comma-separated list of related headers-- headers IDREFS #IMPLIED -- list of id's for header cells -- scope %Scope; #IMPLIED -- scope covered by header cells -- rowspan NUMBER 1 -- number of rows spanned by cell -- colspan NUMBER 1 -- number of cols spanned by cell -- %cellhalign; -- horizontal alignment in cells -- %cellvalign; -- vertical alignment in cells -- >
Here Scope is a parameter entity with the value (row|col|rowgroup|colgroup)
. This entity is then refered to in the declaration of the attribute value list of scope
with the parameter entity reference %Scope;
.
Parameter entities in SGML are like variables and references to such parameter entities are replaced by its values. That means the following two attribute definitions are equal:
<!ENTITY % Scope "(row|col|rowgroup|colgroup)">
<!ATTLIST (FOOBAR)
scope %Scope; #IMPLIED
>
<!ATTLIST (FOOBAR)
scope (row|col|rowgroup|colgroup) #IMPLIED
>
回答2:
Table rows may be grouped into a table head, table foot, and one or more table body sections, using the THEAD, TFOOT and TBODY elements, respectively. This division enables user agents to support scrolling of table bodies independently of the table head and foot. When long tables are printed, the table head and foot information may be repeated on each page that contains table data.
The table head and table foot should contain information about the table's columns. The table body should contain rows of table data.
When present, each THEAD, TFOOT, and TBODY contains a row group. Each row group must contain at least one row, defined by the TR element.
Source: http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3
回答3:
There is no such element, however I think that TBODY
does what you need - contains all the relevant data rows in your table. So, you can create your styles using CSS statements like TBODY TD {color:red}
回答4:
The link that you posted in your question answers the question for you. Row groups are defined by the thead
, tfoot
and tbody
elements. In the other part you mention, rowgroup
is simply a value for the scope
attribute.
回答5:
You can group sections of rows in a table
using
thead
to represent the block of rows that consist of the column labels (headers)tbody
to represent a block of rows that consist of a body of datatfoot
to represent the block of rows that consist of the column summaries (footers)
回答6:
W3C Spec on the th element shows an example of using scope and multiple rowgroups - i.e. multiple tbody
elements.
Note: The tbody
elements in this example identify the range of the row groups.
<table>
<thead>
<tr>
<th> ID
<th> Measurement
<th> Average
<th> Maximum
<**tbody**>
<tr> <td> <th **scope**=rowgroup> Cats <td> <td>
<tr> <td> 93 <th **scope**=row> Legs <td> 3.5 <td> 4
<tr> <td> 10 <th **scope**=row> Tails <td> 1 <td> 1
</**tbody**>
<**tbody**>
<tr> <td> <th **scope**=rowgroup> English speakers <td> <td>
<tr> <td> 32 <th **scope**=row> Legs <td> 2.67 <td> 4
<tr> <td> 35 <th **scope**=row> Tails <td> 0.33 <td> 1
</**tbody**>
</table>
来源:https://stackoverflow.com/questions/2490584/is-there-a-property-named-rowgroup-like-colgroup-in-xhtml