Markdown has no built-in syntax for right-to-left (RTL) text direction. Languages such as Arabic and Hebrew flow from right to left, but most Markdown parsers produce left-to-right output by default. Direction is controlled at the rendering layer — either through the platform, through HTML attributes, or through Unicode directional control characters embedded in the text.
Using HTML for RTL paragraphs
The most reliable cross-platform approach is to use an HTML <p> or <div> tag with the dir="rtl" attribute. This is supported wherever the Markdown renderer passes raw HTML through to the output (CommonMark, GFM, and Pandoc all do this by default).
<p dir="rtl">مرحبًا بك في دليل Markdown العملي.</p>
<p dir="rtl">ברוכים הבאים למדריך המעשי ל-Markdown.</p>
مرحبًا بك في دليل Markdown العملي.
Arabic: "Welcome to the Practical Markdown Guide."
ברוכים הבאים למדריך המעשי ל-Markdown.
Hebrew: "Welcome to the Practical Markdown Guide."
Using Unicode directional markers
Unicode provides invisible control characters that instruct renderers and operating systems to switch text direction without requiring HTML. These can be embedded directly in Markdown source.
| Character | Code point | Purpose |
|---|---|---|
| Right-to-Left Mark | U+200F |
Marks the following text as RTL |
| Right-to-Left Embedding | U+202B |
Opens an RTL embedding scope |
| Pop Directional Formatting | U+202C |
Closes a directional embedding scope |
Support for these characters depends entirely on the rendering environment. They are invisible in source and can be confusing to edit, so the HTML approach is generally preferred.
Notes
Platform support
- GitHub: Raw HTML with
dir="rtl"is stripped from rendered Markdown in issues, comments, and wikis for security reasons. Unicode markers may work depending on the browser and font. - Grav / website: HTML attributes are preserved;
dir="rtl"works reliably. - EPUB readers: Most reading systems respect
dir="rtl"in HTML content. - PDF via Pandoc/Typst: RTL support depends on the font and Typst version; Typst 0.11+ has improved bidirectional text support.
Whole-document direction
If your entire document is in an RTL language, setting direction at the document level (via your platform's template or metadata) is more appropriate than marking every paragraph individually.
Best Practice
- Use
dir="rtl"on individual paragraphs or sections when mixing RTL and LTR text in the same document. - Avoid Unicode directional markers unless you cannot use HTML — they are invisible, hard to audit, and may be stripped by some parsers.
- Test your output in the target rendering environment; RTL support varies considerably between platforms.
Markdown Flavour Support
RTL direction is not part of the Markdown syntax specification in any flavour. Support is entirely platform-dependent.
Flavour Support Detail
| Flavour | Support | Notes |
|---|---|---|
| Original Markdown | Partial | No RTL syntax; raw HTML passthrough enables dir="rtl". |
| CommonMark | Partial | Raw HTML preserved by spec; dir="rtl" works where HTML is rendered. |
| GitHub Flavored Markdown | Limited | Raw HTML attributes including dir are sanitised in most GitHub contexts. |
| Pandoc Markdown | Partial | Raw HTML passed through; Typst/PDF output depends on engine and font. |
Practical Examples
- Adding an Arabic greeting to a travel blog post about a visit to Morocco: A single RTL paragraph can be embedded in an otherwise LTR document using an HTML tag.
The sign above the door read:
<p dir="rtl">أهلاً وسهلاً</p>
*Translation: "أهلاً وسهلاً" — literally "you are among family and ease", a traditional Arabic greeting.*
The sign above the door read:
أهلاً وسهلاً
Translation: "أهلاً وسهلاً" — literally "you are among family and ease", a traditional Arabic greeting.
- Quoting a Hebrew inscription in a history article: An RTL paragraph lets the Hebrew script display correctly within a predominantly English document.
The mosaic beneath our feet bore the words:
<p dir="rtl">שלום עליכם</p>
*Translation: "שלום עליכם" (Shalom aleikhem) — "Peace be upon you", a traditional Hebrew greeting.*
The mosaic beneath our feet bore the words:
שלום עליכם
Translation: "שלום עליכם" (Shalom aleikhem) — "Peace be upon you", a traditional Hebrew greeting.