CSS Reference ยท Properties for Special Contexts
The ruby-position property
Reference for the CSS ruby-position property: place ruby annotations above or below the base text, with syntax, a live example and browser support notes.
Ruby annotations are small notes set next to a word, such as pronunciation guides above East Asian characters. In HTML you write them with <ruby> and <rt>. The ruby-position property decides on which side of the base text those annotations appear.
In horizontal text, the choices are above (over) or below (under) the line. In vertical text, "over" means to the right of the base characters.
rt { ruby-position: under; }
Try it
The example uses Latin text so it looks the same on any system. Real ruby is most often used with Chinese, Japanese or Korean text.
Syntax
ruby-position: over | under | alternate | inter-character;
- Initial value:
alternatein the specification; browsers show annotations over the base text unless told otherwise - Applies to: ruby annotation containers
- Inherited: yes
- Animatable: no (discrete)
- Computed value: as specified
Values
| Value | Description |
|---|---|
over |
Annotation above the base text in horizontal writing, to the right in vertical writing. |
under |
Annotation below the base text in horizontal writing, to the left in vertical writing. |
alternate |
Uses over normally and under when a second annotation is on the other side of the base (double-sided ruby). |
inter-character |
Places annotations to the right of each character; used for Taiwanese Bopomofo. |
Usage notes
- Which element? Set it on
rubyor onrt; it inherits, so the container is usually enough. - Line height. Annotations need room. Increase
line-heightor the lines will collide, as in the example. - Fallback. Wrap annotations in
<rp>(</rp>and<rp>)</rp>so browsers without ruby support show the note in parentheses. - Language conventions. Japanese places furigana over horizontal text; Chinese Bopomofo traditionally sits to the right. Follow the conventions of the language you write.
- Accessibility. Screen readers may read annotations right after the base text. Keep annotations short and accurate.
Browser support
over and under are widely supported in current browsers; alternate and inter-character have patchier support, so check a compatibility table before relying on them.