Skip to main content

Invalid conditional content attribute

markdown
A .content-visible / .content-hidden element carries a condition Quarto does not recognize, or carries both marker classes at once.

Q-2-42 — Invalid conditional content attribute

A .content-visible / .content-hidden element carries a condition Quarto does not recognize, or carries both marker classes at once.

What this means

Conditional content lets one source file produce different output for different formats or profiles:

::: {.content-visible when-format="html"}
Only readers of the HTML version see this.
:::

Quarto recognizes exactly six conditions:

Condition True when
when-format the output format matches
unless-format the output format does not match
when-profile the named project profile is active
unless-profile the named project profile is not active
when-meta the dotted metadata path is present and not false
unless-meta the dotted metadata path is absent or false

This warning fires in two situations. Either the element carries an attribute that starts with when- or unless- but is not one of those six — in which case the attribute is ignored — or the element carries both .content-visible and .content-hidden, which is contradictory.

Both cases are quiet failures, which is why Quarto reports them. Quarto 1 ignores an unrecognized condition silently, so a typo turns into content that is unconditionally visible with no indication that the condition you wrote was never consulted.

Why this happens

  • A typo in the condition name. when-formats, when-format-is, and unless-formats all look right and all do nothing.
  • A condition borrowed from a different feature. when-meta reads document metadata; there is no when-var, when-env, or when-lang.
  • Both marker classes on one element, usually from editing a .content-hidden block into a .content-visible one and leaving the old class behind. The element is treated as .content-hidden.

How to fix

Correct the condition to one of the six recognized spellings:

::: {.content-visible when-format="pdf"}
PDF-only content.
:::

If you meant to key off document metadata, use when-meta with a dotted path into the merged metadata:

::: {.content-visible when-meta="draft"}
Visible while `draft: true` is set in the front matter.
:::

If the element carries both marker classes, delete the one you did not intend:

<!-- before: contradictory -->
::: {.content-visible .content-hidden when-format="html"}

<!-- after -->
::: {.content-visible when-format="html"}

Example

::: {.content-visible when-formats="html"}
This paragraph is *always* visible: `when-formats` is not a condition,
so nothing constrains the block.
:::

Removing the trailing s makes the condition take effect.