Inline
HTML5
The ruby annotation element represents small annotations rendered above, below, or next to base text, typically used for showing pronunciation of East Asian characters or providing translations.
Interactive code playground requires JavaScript. Here's the code:
<ruby>
漢 <rt>kan</rt>
字 <rt>ji</rt>
</ruby>
base text < rt > annotation </ rt >
The <ruby> element contains base text and one or more <rt> (ruby text) elements for annotations.
A complete ruby annotation typically includes:
<ruby> - Container element
Base text - The main content being annotated
<rt> - Ruby text (the annotation)
<rp> - Ruby parentheses (optional, for fallback)
Interactive code playground requires JavaScript. Here's the code:
<ruby>
漢字 <rp>(</rp><rt>kanji</rt><rp>)</rp>
</ruby>
Showing pronunciation of kanji characters:
Interactive code playground requires JavaScript. Here's the code:
<ruby>
日<rt>に</rt>
本<rt>ほん</rt>
語<rt>ご</rt>
</ruby> (Japanese language)
Interactive code playground requires JavaScript. Here's the code:
<ruby>
中<rt>zhōng</rt>
文<rt>wén</rt>
</ruby> (Chinese)
Interactive code playground requires JavaScript. Here's the code:
<ruby>
大<rt>대</rt>
韓<rt>한</rt>
民<rt>민</rt>
國<rt>국</rt>
</ruby> (South Korea)
Interactive code playground requires JavaScript. Here's the code:
<p>The word <ruby>東<rt>tō</rt>京<rt>kyō</rt></ruby> means Tokyo.</p>
Annotating multiple characters as a group:
Interactive code playground requires JavaScript. Here's the code:
<ruby>
明日 <rt>ashita</rt>
</ruby> means tomorrow.
Interactive code playground requires JavaScript. Here's the code:
<ruby>
こんにちは <rt>hello</rt>
</ruby>
The <rp> element provides fallback for browsers that don’t support ruby:
Interactive code playground requires JavaScript. Here's the code:
<ruby>
漢<rp>(</rp><rt>kan</rt><rp>)</rp>
字<rp>(</rp><rt>ji</rt><rp>)</rp>
</ruby>
<!-- In browsers without ruby support, displays: 漢(kan)字(ji) -->
Interactive code playground requires JavaScript. Here's the code:
<p>
<ruby>私<rt>わたし</rt></ruby>は
<ruby>学<rt>がく</rt>生<rt>せい</rt></ruby>です。
</p>
<p>(I am a student.)</p>
Interactive code playground requires JavaScript. Here's the code:
<h4>Chinese Vocabulary</h4>
<ul>
<li><ruby>你<rt>nǐ</rt>好<rt>hǎo</rt></ruby> - Hello</li>
<li><ruby>谢<rt>xiè</rt>谢<rt>xie</rt></ruby> - Thank you</li>
<li><ruby>再<rt>zài</rt>见<rt>jiàn</rt></ruby> - Goodbye</li>
</ul>
Interactive code playground requires JavaScript. Here's the code:
<div class="flashcard">
<h4>Word of the Day</h4>
<p class="word">
<ruby>
桜<rp>(</rp><rt>さくら</rt><rp>)</rp>
</ruby>
</p>
<p class="meaning">Cherry blossom</p>
</div>
Interactive code playground requires JavaScript. Here's the code:
<dl>
<dt>
<ruby>
水<rp>(</rp><rt>みず</rt><rp>)</rp>
</ruby>
</dt>
<dd>Water</dd>
<dt>
<ruby>
火<rp>(</rp><rt>ひ</rt><rp>)</rp>
</ruby>
</dt>
<dd>Fire</dd>
</dl>
Customize ruby annotation appearance:
Interactive code playground requires JavaScript. Here's the code:
<style>
ruby {
font-size: 1.2em;
}
rt {
font-size: 0.6em;
color: #0066cc;
}
rp {
color: #999;
}
</style>
<ruby>
東<rt>tō</rt>
京<rt>kyō</rt>
</ruby>
Interactive code playground requires JavaScript. Here's the code:
<style>
.ruby-below {
ruby-position: under;
}
.ruby-below rt {
color: #d73a49;
}
</style>
<p class="ruby-below">
<ruby>漢<rt>kan</rt>字<rt>ji</rt></ruby>
</p>
Interactive code playground requires JavaScript. Here's the code:
<ruby>
<rb>旧</rb>
<rb>金</rb>
<rb>山</rb>
<rt>サン</rt>
<rt>フラン</rt>
<rt>シスコ</rt>
</ruby> (San Francisco)
Interactive code playground requires JavaScript. Here's the code:
<p>
Welcome to
<ruby>日<rt>に</rt>本<rt>ほん</rt></ruby>!
Enjoy your stay.
</p>
Browser Version Notes Chrome 5+ Full support Firefox 38+ Full support Safari 5+ Full support Edge 79+ Full support IE 5.5+ Partial support
Modern browsers have good support for ruby annotations. Use <rp> for fallback in older browsers.
Screen readers may read both the base text and the ruby annotation, which can be helpful for learning pronunciation.
Always specify the language for proper screen reader pronunciation:
< ruby > 日 < rt > に </ rt > 本 < rt > ほん </ rt ></ ruby >
Too many annotations can be overwhelming:
<!-- Every character annotated -->
< ruby > 私 < rt > わたし </ rt ></ ruby >< ruby > は < rt > は </ rt ></ ruby > ...
<!-- Only difficult characters annotated -->
< ruby > 私 < rt > わたし </ rt ></ ruby > は学生です
Language Use Example Japanese Furigana for kanji <ruby>漢字<rt>かんじ</rt></ruby>Chinese Pinyin pronunciation <ruby>中文<rt>zhōngwén</rt></ruby>Korean Hanja readings <ruby>韓國<rt>한국</rt></ruby>Any Translation notes <ruby>text<rt>translation</rt></ruby>