ruby

Represents a ruby annotation, used for East Asian typography.

Description

The <ruby> element represents a ruby annotation. Ruby annotations are small text above or beside the base text, typically used to show pronunciation of East Asian characters (like furigana in Japanese or pinyin in Chinese).

A ruby annotation consists of the base text and the ruby text (<rt>), with optional fallback parentheses (<rp>) for browsers that don't support ruby.

Basic Example

(かん)()
<ruby> 漢 <rp>(</rp><rt>かん</rt><rp>)</rp> 字 <rp>(</rp><rt>じ</rt><rp>)</rp> </ruby>

Japanese Furigana

Ruby is commonly used to show furigana (pronunciation guides) for kanji:

東京(とうきょう)は日本の首都です。

<p> <ruby>東京<rp>(</rp><rt>とうきょう</rt><rp>)</rp></ruby>は日本の首都です。 </p>

Chinese Pinyin

Ruby can also display pinyin for Chinese characters:

北京 (Běijīng) is the capital of China.

<p> <ruby> 北京 <rp>(</rp><rt>Běijīng</rt><rp>)</rp> </ruby> is the capital of China. </p>

Multiple Ruby Annotations

Multiple ruby elements in a sentence:

明日(あした)天気(てんき)()れです。

<p> <ruby>明日<rp>(</rp><rt>あした</rt><rp>)</rp></ruby>の <ruby>天気<rp>(</rp><rt>てんき</rt><rp>)</rp></ruby>は <ruby>晴<rp>(</rp><rt>は</rt><rp>)</rp></ruby>れです。 </p>

Styling Ruby

Ruby annotations can be styled with CSS:

<style> ruby { ruby-position: under; } rt { font-size: 0.6em; color: #666; } </style> <ruby> 日本語 <rp>(</rp><rt>にほんご</rt><rp>)</rp> </ruby>

The ruby-position property controls whether annotations appear above (over) or below (under) the base text.

Attributes

This element supports global attributes.

Accessibility

Screen readers may read both the base text and ruby text, or just one depending on the implementation. The ruby text provides pronunciation information that benefits learners and those with reading difficulties. The <rp> fallback ensures that in unsupported browsers, the annotation appears in parentheses.

Related Elements

  • <rt> - The ruby text (annotation)
  • <rp> - Fallback parentheses for non-supporting browsers