Back to Content

: The Ruby Annotation element

files/en-us/web/html/reference/elements/ruby/index.md

latest3.7 KB
Original Source

The <ruby> HTML element represents small annotations that are rendered above, below, or next to base text, usually used for showing the pronunciation of East Asian characters. It can also be used for annotating other kinds of text, but this usage is less common.

The term ruby originated as a unit of measurement used by typesetters, representing the smallest size that text can be printed on newsprint while remaining legible.

{{InteractiveExample("HTML Demo: <ruby>", "tabbed-shorter")}}

html
<ruby> 明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp> </ruby>
css
ruby {
  font-size: 2em;
}

Attributes

This element only includes the global attributes.

Examples

Example 1: Character

html
<ruby><rp>(</rp><rt>Kan</rt><rp>)</rp><rp>(</rp><rt>ji</rt><rp>)</rp>
</ruby>

Result

{{EmbedLiveSample('Example 1: Character')}}

Example 2: Word

html
<ruby> 明日 <rp>(</rp><rt>Ashita</rt><rp>)</rp> </ruby>

Result

{{EmbedLiveSample('Example 1: Word')}}

Technical summary

<table class="properties"> <tbody> <tr> <th scope="row"> <a href="/en-US/docs/Web/HTML/Guides/Content_categories" >Content categories</a > </th> <td> <a href="/en-US/docs/Web/HTML/Guides/Content_categories#flow_content" >Flow content</a >, <a href="/en-US/docs/Web/HTML/Guides/Content_categories#phrasing_content" >phrasing content</a >, palpable content. </td> </tr> <tr> <th scope="row">Permitted content</th> <td> One or more groups, each consisting of two parts: <ol> <li>The base text, which is either: <ul> <li><a href="/en-US/docs/Web/HTML/Guides/Content_categories#phrasing_content">Phrasing content</a>, but with no <code>&lt;ruby&gt;</code> elements and with no <code>&lt;ruby&gt;</code> element descendants, or</li> <li>A single <code>&lt;ruby&gt;</code> element that itself has no <code>&lt;ruby&gt;</code> element descendants.</li> </ul> </li> <li>The annotations for the base text, which is either: <ul> <li>One or more {{HTMLElement("rt")}} elements, or</li> <li>An {{HTMLElement("rp")}} element followed by one or more {{HTMLElement("rt")}} elements, each of which is itself followed by an {{HTMLElement("rp")}} element (that is, <code>rp, rt, rp, rt, ..., rp</code>).</li> </ul> </li> </ol> </td> </tr> <tr> <th scope="row">Tag omission</th> <td>None, both the starting and ending tag are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Any element that accepts <a href="/en-US/docs/Web/HTML/Guides/Content_categories#phrasing_content" >phrasing content</a >. </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td> <a href="https://w3c.github.io/html-aria/#dfn-no-corresponding-role" >No corresponding role</a > </td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>Any</td> </tr> <tr> <th scope="row">DOM interface</th> <td>{{domxref("HTMLElement")}}</td> </tr> </tbody> </table>

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{HTMLElement("rt")}}
  • {{HTMLElement("rp")}}
  • {{cssxref("ruby-overhang")}}
  • {{CSSxRef("text-transform")}}: full-size-kana
  • CSS ruby layout module