Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

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 or bopomofo 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>).

Annotations are visible by default on every page, whatever its language. VB adds i18n-aware styling on top: a CJK script face for CJK readings, and an opt-in data-ruby attribute to hide annotations on any part of the page.

When to Use

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

Examples

Set lang on the paragraph (or the <ruby>) so the reading gets the right script face and screen readers the right voice. Tag romanised readings such as pinyin with lang="zh-Latn" so they keep the Latin face.

Mono Ruby vs Group Ruby

Mono ruby pairs each character with its own reading: several base/<rt> pairs inside one <ruby>. Use it when each character's reading is separable, so each reading sits over its own character.

Group ruby gives one reading to a whole word. Use it for compounds whose reading cannot be split per character (jukujikun such as 明日 ashita).

Bopomofo (Zhuyin)

In Taiwan, bopomofo readings are set vertically to the right of each character. Tag the readings lang="zh-Bopo" and VB sets ruby-position: inter-character on the ruby. Firefox and Safari honour it; Chromium ignores the value and keeps the reading above the character.

Ruby Visibility Control

Annotations show unless you hide them. Put data-ruby on any element — <html>, a section, a paragraph, or the <ruby> itself — to control the annotations inside it. The nearest data-ruby wins, so you can hide readings on a whole page and turn them back on for one passage.

Value Behavior
(absent) Visible (browser default)
show Visible. Use it to undo a hide or auto set further out.
hide Visually hidden: the annotation collapses to zero size, so the line gets no extra height. It stays in the accessibility tree, so screen readers still read it.
auto Visible only when the annotation's own language is ja, zh, ko, yue or wuu (from lang on the <rt>, the <ruby> or an ancestor); others are hidden like hide.

Hidden annotations are not visibility: hidden or display: none: both would remove the reading from the accessibility tree. They also stay in the ruby layout (no position: absolute), so showing them again needs no relayout tricks. <rp> stays hidden in every mode — see <rp>.

CSS Reference

Styling Options

Property Effect
ruby-position: over Annotation above base text (default)
ruby-position: under Annotation below base text
ruby-position: inter-character Annotation to the right of each character (bopomofo; Firefox and Safari)
ruby-align: center Center annotation over base text (VB default)
rt font-size 0.5em (VB default)

Line Spacing

A visible annotation needs room above the base text. CJK text already has generous leading (VB sets line-height: 1.8 for ja, zh and ko), so furigana fits inside the line. Latin body text uses 1.5, so a line that carries ruby can grow taller than its neighbours and the spacing looks uneven. If a Latin passage carries a lot of ruby, give it more line height, or hide the annotations with data-ruby="hide".

Accessibility

  • Screen readers handle ruby differently: some read the base text then the annotation, some read only one of them, and some let the user choose
  • Set lang so the base text and the reading are spoken with the right voice
  • data-ruby="hide" and the hidden half of auto only hide the annotation visually; it stays in the accessibility tree
  • In forced-colors mode annotations inherit the system text colour and stay legible
  • Ruby text benefits language learners and those with reading difficulties

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 and ruby-position: over / under are supported in all modern browsers. inter-character is supported in Firefox and Safari. The data-ruby scoping uses CSS @scope (Chrome 118, Safari 17.4, Firefox 146); older browsers ignore it and show every annotation.

↑