Format Content by Cell

Cell styles and their operators

You can style all of the content in an individual cell by adding a style operator to the cell’s specifier.

Style Operator Description

AsciiDoc

a

Supports block elements (lists, delimited blocks, and block macros). This style effectively creates a nested, standalone AsciiDoc document. The parent document’s implicit attributes, such as doctitle, are shadowed and custom attributes are inherited.

Default

d

All of the markup that is permitted in a paragraph (i.e., inline formatting, inline macros) is supported.

Emphasis

e

Text is italicized.

Header

h

Applies the header semantics and styles to the text and cell borders.

Literal

l

Content is treated as if it were inside a literal block.

Monospace

m

Text is rendered using a monospace font.

Strong

s

Text is bold.

When a style operator isn’t explicitly assigned to a cell specifier (or column specifier), the cell falls back to the default (d) style and is processed as regular paragraph text.

Apply a style to a table cell

The style operator is always entered last in a cell specifier. Don’t insert any spaces between the | and the operator.

<factor><span or duplication operator><horizontal alignment operator><vertical alignment operator><style operator>|<cell’s content>

Let’s apply a style operator to each cell in Example 1.

Example 1. Apply a style operator to a cell
|===
|Column 1 |Column 2

2*>m|This content is duplicated across two columns (2*) and aligned to the right side of the cell (>).

It's rendered using a monospace font (m).

.3+^.>s|This cell spans 3 rows (`3+`).
The content is centered horizontally (`+^+`), vertically aligned to the bottom of the cell (`.>`), and styled as strong (`s`).
e|This content is italicized (`e`).

m|This content is rendered using a monospace font (m).

s|This content is bold (`s`).
|===

The table from Example 1 is rendered below.

Result of Example 1
Column 1 Column 2

This content is duplicated across two columns (2*) and aligned to the right side of the cell (>).

It’s rendered using a monospace font (m).

This content is duplicated across two columns (2*) and aligned to the right side of the cell (>).

It’s rendered using a monospace font (m).

This cell spans 3 rows (3+). The content is centered horizontally (^), vertically aligned to the bottom of the cell (.>), and styled as strong (s).

This content is italicized (e).

This content is rendered using a monospace font (m).

This content is bold (s).

Override the column style on a cell

When you assign a style operator to a cell, it overrides the column’s style operator. In Example 2, the style operator assigned to the first column is overridden on two cells. The header row also overrides style operators. However, inline formatting markup is applied in addition to the style specified by an operator.

Example 2. Override the column style using a cell style operator
[cols="m,m"] (1)
|===
|Column 1, header row |Column 2, header row (2)

|This content is rendered using a monospace font because the column's specifier includes the `m` operator.
|This content is rendered using a monospace font because the column's specifier includes the `m` operator.

s|This content is rendered as bold paragraph text because the `s` operator in the cell's specifier overrides the style operator in the column specifier. (3)
|*This content is rendered using a monospace font because the column's specifier includes the `m` operator.
It's also bold because it's marked up with the inline syntax for bold formatting.* (4)

d|This content is rendered as regular paragraph text because the `d` operator in the cell's specifier overrides the style operator in the column specifier. (5)
|This content is rendered using a monospace font because the column's specifier includes the `m` operator.
|===
1 The monospace operator (m) is assigned to both columns.
2 The header row ignores any style operators assigned via column or cell specifiers.
3 The strong operator (s) is assigned to this cell’s specifier, overriding the column’s monospace style.
4 Inline formatting is applied in addition to the style assigned via a column specifier.
5 The default operator (d) is assigned to this cell’s specifier, resetting it to the default text style.

The table from Example 2 is displayed below.

Result of Example 2
Column 1, header row Column 2, header row

This content is rendered using a monospace font because the column’s specifier includes the m operator.

This content is rendered using a monospace font because the column’s specifier includes the m operator.

This content is rendered as bold paragraph text because the s operator in the cell’s specifier overrides the style operator in the column specifier.

This content is rendered using a monospace font because the column’s specifier includes the m operator. It’s also bold because it’s marked up with the inline syntax for bold formatting.

This content is rendered as regular paragraph text because the d operator in the cell’s specifier overrides the style operator in the column specifier.

This content is rendered using a monospace font because the column’s specifier includes the m operator.

Use AsciiDoc block elements in a table cell

To use AsciiDoc block elements, such as delimited source blocks and lists, in a cell, place the a operator directly in front of the cell’s separator (|). Don’t insert any spaces between the | and the operator.

Example 3. Apply the AsciiDoc block style operator to two cells
|===
|Normal Style |AsciiDoc Style

|This cell isn't prefixed with an `a`, so the processor doesn't interpret the following lines as an AsciiDoc list.

* List item 1
* List item 2
* List item 3

a|This cell is prefixed with an `a`, so the processor interprets the following lines as an AsciiDoc list.

* List item 1
* List item 2
* List item 3

|This cell isn't prefixed with an `a`, so the processor doesn't interpret the listing block delimiters or the `source` style.

[source,python]
----
import os
print ("%s" %(os.uname()))
----

a|This cell is prefixed with an `a`, so the listing block is processed and rendered according to the `source` style rules.

[source,python]
----
import os
print "%s" %(os.uname())
----

|===

The table from Example 3 is rendered below.

Result of Example 3
Normal Style AsciiDoc Style

This cell isn’t prefixed with an a, so the processor doesn’t interpret the following lines as an AsciiDoc list.

* List item 1 * List item 2 * List item 3

This cell is prefixed with an a, so the processor interprets the following lines as an AsciiDoc list.

  • List item 1

  • List item 2

  • List item 3

This cell isn’t prefixed with an a, so the processor doesn’t interpret the listing block delimiters or the source style.

[source,python] ---- import os print ("%s" %(os.uname())) ----

This cell is prefixed with an a, so the listing block is processed and rendered according to the source style rules.

import os
print "%s" %(os.uname())

An AsciiDoc table cell effectively creates a nested document. As such, it inherits attributes from the parent document. If an attribute is set or explicitly unset in the parent document, it cannot be modified in the AsciiDoc table cell. There are a handful of exceptions to this rule, which includes doctype, toc, notitle (and its complement, showtitle), and compat-mode. Any newly defined attributes in the AsciiDoc table do not impact the attributes in the parent document. Instead, these attributes are scoped to the table cell.