👀 Live Preview
Styled ruby with Japanese characters:
漢字

The <ruby> tag wraps base text and pronunciation annotations. This guide covers syntax with rt and rp, multilingual and educational use cases, styling, browser support, and best practices for beginners.
Wraps annotations.
Ruby text hints.
Parentheses text.
JP, CN, KR text.
Learning aids.
Semantic markup.
<ruby> Tag?The <ruby> tag is designed for annotating text with pronunciation information, usually in the form of small annotations called ruby text. This is particularly useful for languages like Japanese or Chinese, where characters may have multiple readings.
Place base text and rt annotations inside ruby. Add optional rp for fallback parentheses in non-ruby browsers.
The ruby element is the parent container in modern markup. Do not use deprecated rb or rtc wrappers in new documents.
Include both the base text and the ruby text. The rt tag holds the annotation:
<ruby>
Base Text <rt>Ruby Text</rt>
</ruby><ruby>
漢 <rp>(</rp><rt>kan</rt><rp>)</rp>
</ruby>ruby — no rb wrapper.rt annotation.rt with rp parentheses when fallback support is needed.lang on the page or element for correct typography.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic pattern | <ruby>base<rt>hint</rt></ruby> | Container + rt |
| Annotation | <rt> | Child of ruby |
| Fallback | <rp>(</rp> | Optional |
| Styling | class on ruby | Global attrs |
| Deprecated | rb, rtc | Do not use |
| Browser support | Modern full | IE 10+ partial |
<ruby> vs <rt>| Element | Role | Required? |
|---|---|---|
<ruby> | Annotation container | Yes |
<rt> | Ruby text annotation | Yes (for hints) |
<rp> | Fallback parentheses | Optional |
The <ruby> tag supports global attributes such as class and style, allowing customization of the visual presentation of ruby annotations.
<ruby class="pronunciation" style="font-size: 1.2em;">
漢字 <rt>Kanji</rt>
</ruby>class CSSApply a class to style the ruby group and target rt with CSS.
class="pronunciation"style InlineInline font size or color on the ruby container.
style="font-size: 1.2em"lang LanguageDeclare Japanese, Chinese, or Korean for correct annotation layout.
lang="ja"Use ruby to annotate text for multilingual readers and educational content.
Styled ruby with Japanese characters:
漢字
The <ruby> tag is beneficial for multilingual content and educational materials that need pronunciation assistance.
The ruby tag provides pronunciation assistance for characters or words in different languages.
<ruby>
你好 <rt>Nǐ hǎo</rt>
</ruby>In educational materials, ruby can aid learners in understanding the pronunciation of specific terms or phrases.
<ruby>
<span class="science-term">Photosynthesis</span>
<rt>foh-toh-sin-thuh-sis</rt>
</ruby>Place base text and rt annotations inside ruby.
Ruby-capable user agents render rt as smaller text above the base.
Non-ruby browsers show rp parentheses around annotation text.
Readers see helpful annotations for complex or unfamiliar text.
The <ruby> tag is supported in all modern browsers. Internet Explorer 10 and later has partial ruby support.
Chrome, Firefox, Safari, Edge, and Opera render <ruby> with <rt> annotations correctly.
Bottom line: Use <ruby> with rt and rp for East Asian and educational annotations.
The HTML <ruby> tag is a valuable tool for enhancing the accessibility and understanding of text, particularly in multilingual or educational contexts. By incorporating ruby text annotations with rt, you can provide valuable pronunciation assistance for your audience.
rp for fallback supportlang for East Asian contentrb or rtcrtrt when annotation is neededrp on public pages<ruby>Bookmark these before you annotate text.
Wraps base + rt.
RoleAnnotation text.
StructureJP, CN, KR.
ContextParentheses.
CompatOn ruby.
CSSModern browsers.
Compatibilityrt annotations to show pronunciation or meaning hints.rt for annotations, and optional rp for fallback parentheses.class and style on ruby, and CSS to target rt.rt directly inside ruby.Practice <ruby> with rt for multilingual and educational content in the Try It editor.
6 people found this page helpful