Visible text
The visible text of a node depends on the kind of node.
The visible text of a text node is:
- if the text node is visible, its visible text is its data;
- if the text node is not-visible, rendered, and contains only whitespace, its visible text is the string
" "
(a single ASCII whitespace); - otherwise, the visible text of the text node is the empty string (
""
).
The visible text of an element is:
- if the element is not rendered, its visible text is the empty string (
""
); - if the element is a
<br>
element, its visible text is a newline character ("\n"
); - if the element is a
<p>
element, its visible text is the concatenation a newline character ("\n"
) plus the visible text of its children (in tree order in the flat tree), plus a newline character ("\n"
); - if the computed
display
property of the element has an outer display type ofblock
, or an inner display type oftable-caption
, the visible text of the element is the concatenation of a newline character ("\n"
) plus the visible text of its children (in tree order in the flat tree) plus a newline character ("\n"
); - if the computed
display
property of the element has an inner display type oftable-cell
ortable-row
, the visible text of the element is the concatenation of an ASCII whitespace (" "
) plus the visible text of its children (in tree order in the flat tree) plus an ASCII whitespace (" "
); - otherwise, the visible text of the element is the concatenation of the visible text of its children (in tree order in the flat tree).
The visible text of any other node is the concatenation of the visible text of its children (in tree order in the flat tree).