<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 ( 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>山<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>漢字<rp>(</rp><rt>かんじ</rt><rp>)</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>山<rp>(</rp><rt>yama</rt><rp>)</rp></ruby></p>
<p>Without ruby support:</p>
<p style="font-size:1.5em"><ruby style="display:inline">山<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>漢<rp>(</rp>kan<rp>)</rp></ruby>Right
<ruby>漢<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.