HTML <ruby> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <ruby> element marks small annotations shown above, below, or beside base text — most often pronunciation help for East Asian characters (furigana, pinyin-style hints, and similar).

Put the base text inside <ruby>, then add <rt> for the annotation. Optional <rp> parentheses help when ruby layout is unavailable. Skip deprecated <rb> and <rtc>.

Baseline · Widely available.

Not deprecated. Core ruby support has been stable across browsers since about July 2015 (MDN).

Deprecated companions.

Do not use <rb> or <rtc> in new HTML. Put base text and <rt> directly in <ruby>, or nest <ruby> for two annotation sides.

HTML Syntax

syntax.html
<ruby> base<rt>annotation</rt></ruby>

Both start and end tags are required. Nest groups of base text + <rt> (optionally with <rp> around each <rt>). Parent must accept phrasing content.

Attributes

<ruby> has no element-specific attributes — only globals. These patterns matter most in practice:

PatternDescriptionTry it
<rt>Annotation text (pronunciation or short gloss)Try it
<rp>Fallback parentheses around rt for non-ruby browsersTry it
langLanguage of the base text (e.g. ja, zh-Hans)Try it
Nested <ruby>Two annotation sides; place with ruby-positionTry it

Global Attributes

The <ruby> tag also supports the Global Attributes in HTML.

Live Preview

Switch between per-character annotations, a whole-word reading, and an rp fallback pattern.

annotation style

A real <ruby>. Apply a preset, then inspect the rendered annotations.

Preview

漢かん字じ

Per-character <rt> after each base character.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Per-Character Annotations

Put each base character next to its own <rt>.

HTML
<ruby lang="ja">
  漢<rt>かん</rt>
  字<rt>じ</rt>
</ruby>
Try It Yourself

How It Works

  1. Open <ruby>. Optionally set lang for the base script.
  2. Write the base character as plain text (no rb needed).
  3. Follow with <rt>. That is the reading for that character.
  4. Repeat for each character you want annotated.

Example 2 — Whole-Word Annotation

One <rt> can annotate an entire word or phrase as a single unit.

HTML
<ruby lang="ja">
  明日<rt>Ashita</rt>
</ruby>
Try It Yourself

How It Works

  1. Group the base text that shares one reading (here, 明日).
  2. Add a single <rt> with that reading or romanization.
  3. Prefer word-level when the reading applies to the compound, not each glyph alone.
  4. Keep rt short so the annotation stays readable.

Example 3 — Fallback with rp

Wrap each rt in parentheses so non-ruby browsers still show a clear reading.

HTML
<ruby lang="ja">
  漢<rp>(</rp><rt>Kan</rt><rp>)</rp>
  字<rp>(</rp><rt>ji</rt><rp>)</rp>
</ruby>
Try It Yourself

How It Works

  1. Keep base + rt as usual inside ruby.
  2. Add <rp>(</rp> before each rt.
  3. Add <rp>)</rp> after each rt.
  4. Ruby-capable browsers hide the parentheses; others show text like 漢(Kan).

Example 4 — Nested ruby (Two Sides)

For reading + meaning without deprecated rtc, nest ruby and place sides with CSS.

HTML
<style>
  .double { ruby-position: under; }
  .double ruby { ruby-position: over; }
</style>

<ruby class="double" lang="ja">
  <ruby>東<rt>とう</rt></ruby>
  <rt>east</rt>
</ruby>
Try It Yourself

How It Works

  1. Inner ruby holds the base and the first annotation (e.g. kana).
  2. Outer ruby wraps that unit and adds a second rt (e.g. English).
  3. Set ruby-position so one side is over and the other under.
  4. Prefer this over rtc for clearer cross-engine results.

Edge Cases & Pitfalls

Most ruby bugs come from legacy wrappers, missing language hints, or overcrowded annotations.

deprecated

Skip rb and rtc

Put base text and rt directly in ruby. See <rb> and <rtc> only for legacy recognition.

lang

Declare the base language

Set lang on ruby or an ancestor so assistive tech and fonts handle the script correctly.

fallback

Add rp when readers may lack ruby layout

Parentheses keep readings understandable as plain text. Harmless in modern ruby browsers.

a11y

Keep annotations short

Long glosses crowd the line. Prefer brief rt text; expand meaning in nearby prose when needed.

layout

Two sides need nesting + CSS

Use nested ruby with ruby-position. Do not rely on deprecated rtc for new pages.

Browser Support

The <ruby> element is core HTML phrasing content in modern browsers. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<ruby>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support basic ruby + rt. Nested / double-sided layout quality can still vary — test when you nest.

95% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer IE 10+ (partial)
Partial
<ruby> Widely supported

Bottom line: Safe for modern sites. Use ruby + rt (and optional rp); nest for two sides; skip rb and rtc.

Key Takeaways

  • Role: <ruby> wraps base text and small pronunciation (or gloss) annotations.
  • Children: use <rt>; add <rp> for fallback parentheses.
  • Two sides: nest ruby and place with ruby-position — not rtc.
  • Legacy: skip deprecated <rb> / <rtc>.

One line: wrap base + <rt> in <ruby>; add <rp> when you want fallback parentheses.

Default CSS Settings

Typical user-agent mapping for ruby-related display values (engines may vary):

default.css
ruby {
  display: ruby;
}

rt {
  display: ruby-text;
  font-size: 50%; /* often smaller than the base */
}

rp {
  display: none; /* shown only when ruby layout is unavailable */
}

You can restyle with CSS (size, color, ruby-position). Prefer selectors on ruby and rt — not on deprecated rtc / rb.

Frequently Asked Questions

The ruby element wraps base text and small annotations (usually pronunciation) shown above, below, or beside the base — common for East Asian characters (furigana / pinyin-style hints).
Base text plus one or more rt annotations. Optionally wrap each rt with rp parentheses for fallback display. Do not use deprecated rb or rtc in new pages.
rp is optional but useful. It provides fallback parentheses when a browser cannot lay out ruby, so text still reads like 漢(かん).
No element-specific attributes. Use global attributes such as lang, class, and id. Set lang on ruby (or an ancestor) for the correct language of the base text.
Nest ruby elements and place each side with CSS ruby-position (over / under). Avoid deprecated rtc containers for new work.
No. ruby is Baseline and widely available (since about July 2015). Related legacy elements rb and rtc are deprecated — keep using ruby, rt, and rp.

Next: s

Mark text that is no longer accurate with the HTML s element.

s tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful