ruby

Represents a ruby annotation, used for East Asian typography to show pronunciation guides above or beside base text.

Description

The <ruby> element represents a ruby annotation — small text above or beside base text, typically showing pronunciation. Ruby annotations are essential for East Asian typography (furigana in Japanese, pinyin in Chinese) but can also help with pronunciation guides in any language.

A ruby annotation consists of base text, ruby text (<rt>), and optional fallback parentheses (<rp>).

VB provides i18n-aware styling: CJK script fonts for ruby text, and a data-ruby visibility system to control when annotations appear.

When to Use

  • Japanese furigana: Pronunciation guides for kanji
  • Chinese pinyin: Romanized pronunciation for Chinese characters
  • Korean: Hanja pronunciation guides
  • Language learning: Pronunciation for unfamiliar words in any language
  • Accessibility: Helping users with reading difficulties

Examples

Ruby Visibility Control

VB's i18n system provides a data-ruby attribute on <html> to control when annotations display:

Value Behavior
show Always visible
hide Visually hidden, kept in DOM for screen readers
auto Visible for CJK languages (ja, zh, ko), hidden otherwise
(absent) Browser default (always visible)

CSS Reference

Styling Options

Property Effect
ruby-position: over Annotation above base text (default)
ruby-position: under Annotation below base text
ruby-align: center Center annotation over base text (VB default)
rt font-size 0.5em (VB default)

Accessibility

  • Screen readers may read both base text and ruby text, or provide options for users to hear annotations
  • The <rp> fallback ensures annotations appear in parentheses when ruby is not supported
  • Ruby text benefits language learners and those with reading difficulties
  • The data-ruby="hide" mode keeps annotations in the DOM for accessibility even when visually hidden

Related

  • <rt> — The ruby text (annotation content)
  • <rp> — Fallback parentheses for non-supporting browsers
  • <bdi> — Bidirectional isolation for mixed-script text
  • <bdo> — Bidirectional direction override
  • Internationalization guide — Script-specific typography, ruby visibility, locale quotes

Browser Support

Ruby annotations are supported in all modern browsers. The ruby-position CSS property is supported in Chrome, Edge, Safari, and Firefox 38+.