HTML - <rp> Tag



HTML <rp> tag is used to provide fallback parenthesis around a ruby text for browsers that do not support the display of ruby annotations using the <ruby> tag. This is a new tag included in HTML5. The <rp> tag must enclose the <rt> tag with parenthesis, which contains the annotation’s text.

Syntax

<rp>.....</rp>

Attribute

HTML rp tag supports Global and Event attributes of HTML.

Examples of HTML rp Tag

In the following examples we will see the use cases, where and how to use the HTML rp tag to provide fallback parenthesis around a ruby text.

Enclosing Ruby Text using rp Tag

In the following example, we are creating a ruby text enclose using the <rp> tag.

<!DOCTYPE html>
<html>
<head>
   <style>
      ruby {
         font-size: 2em;
      }
   </style>
</head>
<body>
   <ruby> 漢 <rp>(</rp>
      <rt>kan</rt>
      <rp>)</rp> 字 <rp>(</rp>
      <rt>ji</rt>
      <rp>)</rp>
   </ruby>
</body>
</html>

Styling the rp Element

Considering the following example, we are creating an HTML document using the <rp> tag and styling it with CSS properties.

<!DOCTYPE html>
<html>
<head>
   <style>
      body {
         text-align: center;
      }

      ruby {
         font-size: 3em;
         color: green;
      }
   </style>
</head>
<body>
   <h3>HTML rp Tag</h3>
   <ruby> 漢 <rp>(</rp>
      <rt>kan</rt>
      <rp>)</rp> 字 <rp>(</rp>
      <rt>ji</rt>
      <rp>)</rp>
   </ruby>
</body>
</html>

Applying rp tag on unsupported Ruby Annotation

Let's look at the following example, where we are going to use the <rp> element to display parenthesis to user agents that don’t support Ruby annotations.

<!DOCTYPE html>
<html>
<head>
   <style>
      body {
      text-align: center;
      }

      ruby {
      font-size: 2em;
      color: #808000;
      }
   </style>
</head>
<body>
   <h3>Example of rp tag </h3>
   <ruby> 漢 <rp>(</rp>
      <rt>かん</rt>
      <rp>)</rp> 字 <rp>(</rp>
      <rt>じ</rt>
      <rp>)</rp>
   </ruby>
</body>
</html>

Supported Browsers

Tag Chrome Edge Firefox Safari Opera
rp Yes 5.0 Yes 5.5 Yes 38.0 Yes 5.0 Yes 15.0
html_tags_reference.htm
Advertisements