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.

Example 1. Table with 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.

Result of Example 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

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.

Example 2. Table with header assigned to the options attribute
[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.

Result of Example 2
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:

  1. The first line of content inside the table delimiters is not empty.

  2. The second line of content inside the table delimiters is empty.

Example 3. First row is implicitly assigned 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
|===

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.

Result of Example 3
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.

Example 4. Deactivate implicit header row with noheader
[%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.

Result of Example 4

Cell in column 1, row 1

Cell in column 2, row 1

Cell in column 1, row 2

Cell in column 2, row 2