HTML <rp> Tag
The <rp>
tag in HTML is used to define what content to display when a browser does not support ruby annotations. Ruby annotations are used to provide pronunciation guides for East Asian characters, and the <rp>
tag provides fallback parentheses around the ruby text for browsers that don't understand the <ruby>
and <rt>
tags. This helps to make ruby text somewhat understandable even in older or unsupported browsers.
Syntax
<rp>fallback text</rp>
Attributes
Attribute | Value | Description |
---|---|---|
None | None | The <rp> tag does not have any specific attributes. |
Example
<ruby>
漢 <rp>(</rp><rt>kan</rt><rp>)</rp>
</ruby>
More Examples
Basic Ruby with Fallback
This example demonstrates the basic usage of the <rp>
tag within a <ruby>
element. If a browser doesn't support ruby, it will display "漢(kan)". Otherwise, it will show "漢" with "kan" as a ruby annotation and no parentheses.
<p>
<ruby>
漢 <rp>(</rp><rt>kan</rt><rp>)</rp>
</ruby> 字
</p>
Multiple Ruby Annotations
This example shows multiple ruby annotations in one paragraph and using parentheses fallback.
<p>
<ruby>
東 <rp>(</rp><rt>tō</rt><rp>)</rp>
</ruby>
<ruby>
京 <rp>(</rp><rt>kyō</rt><rp>)</rp>
</ruby>
</p>
Complex Text
A more complex text with multiple words showing their pronunciation with ruby text and parenthesis fallback
<p>
<ruby>
日本語 <rp>(</rp><rt>nihongo</rt><rp>)</rp>
</ruby>
を
<ruby>
勉強 <rp>(</rp><rt>benkyō</rt><rp>)</rp>
</ruby>
します。
</p>
Real World Example
Imagine a webpage for learning Japanese. The user needs to know the correct pronunciation of Kanji characters.
<!DOCTYPE html>
<html>
<head>
<title>Japanese Learning</title>
</head>
<body>
<p> Today we will learn:
<ruby>
私 <rp>(</rp><rt>watashi</rt><rp>)</rp>
</ruby>
は
<ruby>
学生 <rp>(</rp><rt>gakusei</rt><rp>)</rp>
</ruby>
です。
</p>
</body>
</html>
Browser Support
The <rp>
tag is supported by all modern browsers.
- Chrome
- Edge
- Firefox
- Safari
- Opera
Older browsers that do not support the <ruby>
tag will show the fallback content, including the parentheses.
Notes and Tips
- The
<rp>
tag must be used within the<ruby>
tag, alongside with<rb>
and<rt>
tags. - The primary purpose is to enhance accessibility for those browsers that do not render ruby annotations.
- When using
<rp>
, the text provided should usually be a set of parentheses()
or similar symbols that can clearly indicate the presence of ruby text. - While all major modern browsers support ruby text, some older browsers do not; Using
<rp>
ensures a basic level of readability for all users. - Do not include any attributes in the
<rp>
tag, because it is only used for fallback content. - Keep the fallback content short and simple.
- The
<rp>
tag is not used when the browser properly renders ruby text, it's only a fallback mechanism.