MyST Markdown has support for inline attributes for both roles and directives, allowing concise specification of CSS classes, IDs, and attributes. This complements other methods for defining options, making markup more expressive and flexible.
:::{tip .dropdown open="true"} Title
Tip Content
:::
This can also be used for roles:
{span .text-red-500}`Red text`
Red text
Syntax Overview¶
The inline attribute syntax follows this pattern:
{role #id .class key="value" key=value}`content`
```{directive #id .class key="value" key=value}
content
```
- Name (e.g.
tip
orcite:p
) - The directive or role name must come first. There must only be a single “bare” token.
- ID (
#id
) - Defines the label/identifier of the node
- Class (
.class
) - Adds CSS class(es).
- Quoted Attributes (
key="value"
) - Supports attributes containing spaces or special characters.
- Unquoted Attributes (
key=value
orkey=123
) - Allows simpler attribute values when there are no spaces.
For directives, these can be mixed with other ways to define options on directives, classes are combined in a single space-separated string; other repeated directive options will raise a duplicate option warning.