Tables
Use the table element to arrange data into rows and columns for easier reading. Mallard tables are designed to make it easy to handle common formatting needs.
Notes
-
The table element contains the following content:
The table element can occur in any general block context, including inside pages, sections, and certain block elements.
The style attribute takes a space-separated list of style hints. Processing tools should adjust their behavior according to those style hints they understand.
The frame attribute controls the frame around the entire table. Valid values are "all", "none", or a space-separated list of the values "top", "bottom", "left", and "right".
The rules attribute controls lines between rows and columns. Valid values are "all", "groups", "none", or a space-separated list of "rows", "rowgroups", "cols", and "colgroups".
The shade attribute controls shading of alternating rows and columns. Valid values are "all", "groups", "none", or a space-separated list of "rows", "rowgroups", "cols", and "colgroups".
The table element can have attributes from external namespaces. See External Namespaces for more information on external-namespace attributes.
Examples
Processing Expectations
The basic layout of tables, rows, columns, and cells follows the layout model for the similarly named elements in HTML, including row and column spanning. Mallard does not provide a means to control spacing, colors, or other stylistic effects you can control in HTML, nor does it make any guarantee about how processing tools will choose these effects.
Unlike HTML, Mallard does not consider each table cell to have its own border. Instead, there is a frame around the entire table, and rules between rows and columns. This is similar to setting the border-collapse CSS property on HTML tables.
A frame is drawn on the top, bottom, left, or right sides of the table if the corresponding value appears in the space-separated list in the frame attribute. If the frame attribute is simply "all", a frame is drawn on all sides of the table.
If the space-separated rules attribute contains the value rows or if it is set to "all", then a rule is drawn between each successive row. If the rules attribute contains the value rowgroups or if it is set to "groups", then a rule is drawn between successive rows if they do not belong to the same thead, tbody, or tfoot element.
If the space-separated rules attribute contains the value cols or if it is set to "all", then a rule is drawn between each successive column. If the rules attribute contains the value colgroups or if it is set to "groups", then a rule is drawn between successive columns if their corresponding col elements do not belong to the same colgroup element.
Mallard tables can shade alternating rows, columns, row groups, or column groups. A cell in a shaded row or column is drawn with a slightly darker background color, or a lighter color in a light-on-dark rendering. If a cell is in both a shaded row and a shaded column, it is drawn with an even darker background color, or an even lighter color in a light-on-dark rendering.
If the space-separated shade attribute contains the value rows or if it is set to "all", then every other row is shaded. If the shade attribute contains the value rowgroups or if it is set to "groups", then rows in every other thead, tbody, and tfoot element are shaded.
If the space-separated shade attribute contains the value cols or if it is set to "all", then every other column is shaded. If the shade attribute contains the value colgroups or if it is set to "groups", then columns in every other group are shaded, where two columns are in the same group if their corresponding col elements are in the same colgroup element.
When cells span multiple rows or columns, they are considered to be in their starting row and column for the purpose of shading.
The optional info element can provide metadata for the table, such as attributions, licensing information, and additional titles for extensions. It is not displayed directly.
Comparison to Other Formats
The table element is similar to the table element in DocBook. DocBook allows either CALS or HTML tables to be used in the table element. Mallard tables follow the HTML model. Like Mallard, DocBook treats frames, row separators, and column separators as belonging to the table, rather than to individual cells. Mallard provides more flexibility in controlling these.
The table element serves the same purpose as the table element in DITA, although DITA uses the CALS table model exclusively. Like Mallard, DITA treats the frames, row separators, and column separators as belonging to the table, rather than to individual cells. Mallard provides more flexibility in controlling these.
Schema
The formal definition of the Mallard language is maintained in RELAX NG Compact Syntax in code blocks within this specification. This is the formal definition for the table element. The namespace declarations for this definition are on the page Pages.
mal_table = element table {
mal_table_attr,
mal_info ?,
mal_block_title ?,
mal_block_desc ?,
( mal_table_col + |
mal_table_colgroup +
) ?,
( mal_table_tr + |
( mal_table_thead ?,
mal_table_tbody +,
mal_table_tfoot ?
)
)
}
mal_table_attr = (
attribute style { xsd:NMTOKENS } ?,
attribute frame {
"all" | "none" |
list { ("top" | "bottom" | "left" | "right") * }
} ?,
attribute rules {
"all" | "groups" | "none" |
list { ("rows" | "rowgroups" | "cols" | "colgroups") * }
} ?,
attribute shade {
"all" | "groups" | "none" |
list { ("rows" | "rowgroups" | "cols" | "colgroups") * }
} ?,
mal_block_attr,
mal_attr_external *
)