<rp> Ruby fallback parenthesis

Fallback brackets around ruby text, shown only where ruby is unsupported.

<rp> wraps parentheses or other punctuation that only a browser without ruby support will display. Browsers that understand ruby hide it.

Add one rp before each <rt> and one after it. An old browser then prints the reading in brackets right after the base text. Every modern browser supports ruby, so rp is optional today.

The rp element in the WHATWG standard (opens in a new tab) shows the parentheses working as a fallback. For the complete structure, read the ruby element page.

Syntax

<ruby>
  Base<rp>(</rp><rt>annotation</rt><rp>)</rp>
</ruby>

When to use it

Ruby text doesn't always land in a browser. Feed readers, some email clients, text-only browsers and tools that strip CSS show it flat, and without <rp> the base text and the reading run together into one confusing word. With rp, a vocabulary list reads kanji (reading) instead.

Plenty of sites skip it, and if your content only ever appears in modern browsers it adds little. Pick brackets that suit the language. English learning material tends to use round ones. Japanese text usually takes full-width brackets, and you can write those as character references such as &#xFF08; to keep the file ASCII.

An rp has to be a direct child of ruby, right before and after an rt. Type the brackets as plain text and supporting browsers will show them stacked above or beside the base, which looks broken. And never give rp display:inline in your CSS, or the hidden brackets turn up in every browser.

Live example

Edit the code and watch the preview.

<p style="font-size:2em"><ruby>&#x5C71;<rp>(</rp><rt>yama</rt><rp>)</rp></ruby></p>

More examples

Full-width brackets for Japanese

Japanese text normally uses full-width parentheses. Here they are numeric character references inside <rp>. Browsers that render ruby hide them; everywhere else they show up as the fallback.

<p lang="ja" style="font-size:2em">
  <ruby>&#x6F22;&#x5B57;<rp>&#xFF08;</rp><rt>&#x304B;&#x3093;&#x3058;</rt><rp>&#xFF09;</rp></ruby>
</p>

What the fallback looks like

The second line fakes a browser with no ruby support by forcing ruby, rt and rp to display inline with inline styles. Thanks to rp, the reading comes out as a bracketed note and not a jumble of letters.

<p>With ruby support:</p>
<p style="font-size:1.5em"><ruby>&#x5C71;<rp>(</rp><rt>yama</rt><rp>)</rp></ruby></p>
<p>Without ruby support:</p>
<p style="font-size:1.5em"><ruby style="display:inline">&#x5C71;<rp style="display:inline">(</rp><rt style="display:inline;font-size:1em">yama</rt><rp style="display:inline">)</rp></ruby></p>

Tip: Give each rt an rp before it and an rp after it.

Browser support

rp is standard HTML. Every current browser hides it with a built-in display:none style whenever it renders ruby. Browsers rarely need the fallback today. It is still valid, it does no harm, and it helps when your content gets read outside a browser.

Accessibility

Some screen readers speak the rp parentheses, so stick to plain brackets. Ruby itself has wide support now; see the Can I use ruby table (opens in a new tab).

Common mistakes

Wrong

<ruby>&#28450;<rp>(</rp>kan<rp>)</rp></ruby>

Right

<ruby>&#28450;<rp>(</rp><rt>kan</rt><rp>)</rp></ruby>

rp adds the parentheses and nothing else. The annotation still goes in an rt.

Frequently asked questions

What is the rp tag for?

<rp> holds the parenthesis characters around an <rt> annotation. Ruby-aware browsers hide whatever is in rp. Older browsers and text-only tools show it, so the reader sees base(annotation) and the two parts do not run together. One rp goes before the rt, one after.

Do I need rp inside ruby?

No, it is optional, and all modern browsers lay out ruby correctly. It still helps when your content ends up as plain text: copied and pasted, read in a feed, or shown by a tool that ignores ruby styling. In those places the parentheses keep base text and annotation visibly apart.

Related text elements

<p>One paragraph of text.<br>Breaks the line inside text, as in a postal address or a poem.<hr>A change of topic between paragraphs, drawn as a horizontal line.<pre>Shows text exactly as typed, spaces and line breaks included.<blockquote>A longer quotation from another source, set apart as its own block.<div>A generic block box with no meaning, for grouping and styling.<span>A generic inline wrapper with no meaning, for styling part of a line of text.<strong>Text that is important, serious or urgent. Shown in bold by default.<em>Stress emphasis that changes what a sentence means. Italic by default.<b>Makes text stand out without adding importance, as with keywords. Bold by default.<i>Text in another voice: foreign words, terms, thoughts, ship names. Italic.<u>Text with an unspoken annotation, such as a flagged spelling error.<s>Content that is no longer accurate or relevant, drawn crossed out.<mark>Highlighted text, like a marker pen, showing relevance in the current context.<small>Side comments and fine print, like copyright lines or legal notes.<sub>Subscript text, set below the line, as in H2O.<sup>Superscript text, set above the line, as in exponents or 1st.<code>A fragment of computer code, set in a monospace font.<kbd>Keys or text the user should press or type.<samp>Sample output from a program or a computer system.<var>A variable in math or in code. Italic by default.<q>A short quotation inside a sentence. The browser adds the quote marks.<cite>The title of a creative work: a book, film, song, game or article.<abbr>An abbreviation or acronym, with an optional expansion in title.<dfn>Marks the term that the surrounding sentence or paragraph defines.<time>Marks a date, time or duration and gives it a machine-readable value.<data>Ties visible content to a machine-readable value.<del>Text that was removed from the document. Struck through by default.<ins>Text that was added to the document. Underlined by default.<wbr>A spot where the browser may break a long word if it has to.<bdi>Isolates text of unknown direction, such as user names.<bdo>Forces a text direction and overrides the normal bidi algorithm.<ruby>Small annotations above or beside text, mostly for East Asian pronunciation.<rt>The small reading or note in a ruby annotation.