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…
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-rubyattribute 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.
<p><rubylang="zh">北京<rp>(</rp><rtlang="zh-Latn">Běijīng</rt><rp>)</rp></ruby> is the capital of China.</p>
English pronunciation
123
<p> How to pronounce <ruby>Versailles<rp>(</rp><rt>vair-SIGH</rt><rp>)</rp></ruby>.</p>
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).
Mono ruby (per character)
1
<rubylang="ja">漢<rt>かん</rt>字<rt>じ</rt></ruby>
Group ruby (one reading for the compound)
1
<rubylang="ja">明日<rt>あした</rt></ruby>
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.
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.
Ruby visibility markup
1234567891011121314151617
<htmllang="ja"data-ruby="auto"><body><!-- Visible: the annotation's language is ja --><ruby>漢字<rt>かんじ</rt></ruby><sectionlang="en"><!-- Hidden: the annotation's language is en --><ruby>ruby<rt>annotation</rt></ruby></section><!-- Readings hidden for a reading test, except one passage --><articledata-ruby="hide"><p><ruby>試験<rt>しけん</rt></ruby></p><pdata-ruby="show"><ruby>例<rt>れい</rt></ruby></p></article></body></html>
Ruby visibility CSS
123456789101112131415161718
/* hide: from the nearest [data-ruby="hide"] down to the next [data-ruby] */@scope ([data-ruby="hide"]) to ([data-ruby]) {:scope:is(rt), rt {font-size: 0;line-height: 0;clip-path: inset(50%); }}/* auto: hide annotations whose own language is not CJK */@scope ([data-ruby="auto"]) to ([data-ruby]) { rt:not(:lang(ja), :lang(zh), :lang(ko), :lang(yue), :lang(wuu)) {font-size: 0;line-height: 0;clip-path: inset(50%); }}
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
Ruby CSS (VB defaults)
1234567891011121314151617181920212223242526
ruby {display: ruby;}rt {font-size: 0.5em;line-height: 1;ruby-align: center;}rp {display: none; /* re-asserts the UA rule */}/* CJK readings use the CJK face; romanised readings keep the body face */rt:is(:lang(ja), :lang(zh), :lang(ko), :lang(yue), :lang(wuu)):not(:lang(ja-Latn), :lang(zh-Latn), :lang(ko-Latn), :lang(yue-Latn), :lang(wuu-Latn)) {font-family: var(--font-cjk);}rt:is(:lang(ja-Latn), :lang(zh-Latn), :lang(ko-Latn), :lang(yue-Latn), :lang(wuu-Latn)) {font-family: var(--font-sans);}/* Bopomofo to the right of each character */ruby:has(> rt:lang(zh-Bopo)) {ruby-position: inter-character;}
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
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.