W3docs

HTML <rp> Tag

The <rp> tag defines an alternative text, which is displayed in the browsers not supporting the <ruby> tag.

The <rp> (ruby parenthesis) tag provides fallback parentheses for browsers that don't support the <ruby> element. Ruby annotations are small bits of text shown alongside a base character to indicate its pronunciation or meaning — a convention used heavily in East Asian (Japanese, Chinese) publications.

The <rp> tag is one of the HTML5 elements.

How <ruby>, <rt>, and <rp> work together

A ruby annotation is built from three elements that play distinct roles:

  • <ruby> — the container that wraps the base text and its annotation.
  • <rt> (ruby text) — the actual annotation, the pronunciation or note rendered above (or beside) the base character.
  • <rp> (ruby parenthesis) — the fallback characters, usually ( and ), that wrap the annotation only when ruby isn't supported.

The key idea is the split rendering:

  • Browsers that support ruby hide the contents of every <rp> element and display the <rt> annotation in its proper position (above the base text). The reader never sees the parentheses.
  • Browsers that do not support ruby ignore the positioning and render everything inline. The <rp> parentheses then become visible, so 漢字(Kanji) reads sensibly as plain text instead of an ambiguous 漢字Kanji.

You place one <rp> before the <rt> (the opening parenthesis) and one after it (the closing parenthesis) so the annotation is wrapped on both sides in the fallback case.

Syntax

The <rp> element is written with a start tag and an end tag. Per HTML5, the end tag (</rp>) is optional: it may be omitted if the <rp> element is immediately followed by another <rp> or <rt> element, or if there is no more content in the parent <ruby> element. Including it is always safe and is recommended for clarity.

Example of the HTML <rp> tag:

HTML <rp> Tag

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <ruby>
    漢 <rp>(</rp><rt>Kan</rt><rp>)</rp>
    字 <rp>(</rp><rt>ji</rt><rp>)</rp>
    </ruby>
  </body>
</html>

Result

rp tag example

In a ruby-supporting browser, the output reads "Kan ji" above "漢字" and the parentheses stay hidden. In a browser without ruby support, the same markup degrades to the inline text 漢(Kan)字(ji) — the <rp> parentheses keep the annotation readable.

Attributes

The<rp> tag supports the Global Attributes and the Event Attributes.

  • <ruby> — the container for a ruby annotation.
  • <rt> — the ruby annotation text (pronunciation or note).
  • <rb> — marks the base text of a ruby annotation.

Practice

Practice
What is the HTML <rp> tag used for in HTML encoding?
What is the HTML <rp> tag used for in HTML encoding?
Was this page helpful?