Create a Header Row
The first row of a table is promoted to a header row if the header
value is assigned to the table’s options
attribute.
You can assign header
to a table’s first row explicitly or implicitly.
The header row ignores any style operators assigned via column and cell specifiers. It also ignores alignment operators assigned to the table’s column specifiers; however, any alignment operators assigned to a cell specifier in the header row are applied. |
Explicitly assign header to the first row
The header row semantics and styles are explicitly assigned to the first row in a table by assigning header
to the options
attribute.
The options
attribute is set in the table’s attribute list using the shorthand (%value
) or formal syntax (options="value"
).
The options
attribute is represented by the percent sign (%
) when it’s set using the shorthand syntax.
In Example 1, header
is assigned to using the shorthand syntax for options
.
header
assigned using the shorthand syntax[%header,cols="2,2,1"] (1)
|===
|Column 1, header row
|Column 2, header row
|Column 3, header row
|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 3, row 2
|===
1 | Values assigned using the shorthand syntax must be entered before the cols attribute (or any other named attributes) in a table’s attribute list, otherwise the processor will ignore them. |
The table from Example 1 is displayed below.
Column 1, header row | Column 2, header row | Column 3, header row |
---|---|---|
Cell in column 1, row 2 |
Cell in column 2, row 2 |
Cell in column 3, row 2 |
In Example 2, the options
attribute is set and assigned the header
value using the formal syntax.
The options
attribute accepts a comma-separated list of values.
[cols="2*",options="header"]
|===
|Column 1, header row
|Column 2, header row
|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 1, row 3
|Cell in column 2, row 3
|===
The first row of the table in Example 2 is rendered using the corresponding header styles and semantics.
Column 1, header row | Column 2, header row |
---|---|
Cell in column 1, row 2 |
Cell in column 2, row 2 |
Cell in column 1, row 3 |
Cell in column 2, row 3 |
Implicitly assign header to the first row
You can implicitly define a header row based on how you layout the table. The following conventions determine when the first row automatically becomes the header row:
-
The first line of content inside the table delimiters is not empty.
-
The second line of content inside the table delimiters is empty.
|===
|Column 1, header row |Column 2, header row
|Cell in column 1, row 2
|Cell in column 2, row 2
|Cell in column 1, row 3
|Cell in column 2, row 3
|===
As seen in the result below, if all of these rules hold true, then the first row of the table is treated as a header row.
Column 1, header row | Column 2, header row |
---|---|
Cell in column 1, row 2 |
Cell in column 2, row 2 |
Cell in column 1, row 3 |
Cell in column 2, row 3 |
Deactivate the implicit assignment of header
To suppress the implicit behavior of promoting the first row to a header row, assign the value noheader
to the options
attribute using the formal (options=noheader
) or shorthand (%noheader
) syntax.
In Example 4, noheader
is assigned using the shorthand syntax.
[%noheader]
|===
|Cell in column 1, row 1 |Cell in column 2, row 1
|Cell in column 1, row 2 |Cell in column 2, row 2
|===
The table from Example 4 is displayed below.
Cell in column 1, row 1 |
Cell in column 2, row 1 |
Cell in column 1, row 2 |
Cell in column 2, row 2 |