Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Properties for Special Contexts

The ruby-align property

Reference for the CSS ruby-align property: control how ruby annotations are distributed when base text and annotation have different widths, with examples.

When a ruby annotation and its base text have different widths, the narrower one has to be aligned inside the width of the wider one. The ruby-align property chooses how: pinned to the start, centered, or spread out with space between or around the characters.

CSS
ruby {
  ruby-align: center;
}

Try it

The base word is wide and the annotation is short, so the alignment is easy to see. Latin text is used so every system renders it the same.

Aligning a short annotation

Syntax

CSS
ruby-align: start | center | space-between | space-around;
  • Initial value: space-around
  • Applies to: ruby base and annotation containers
  • Inherited: yes
  • Animatable: no (discrete)
  • Computed value: as specified

Values

Value Description
start The contents sit at the start edge, with no extra spacing.
center The contents are centered.
space-between Extra space is placed between items, none at the ends.
space-around Extra space is shared around items, with half-size space at each end. This is the default.

Usage notes

  • It distributes items, not letters. The spacing applies between the characters or groups of a ruby, so a one-character annotation behaves like center for space-around.
  • Per-element. Set it on ruby (inherited by its children) or on a specific rt.
  • Pairs well with ruby-position when controlling the overall look of annotations.
  • Typographic traditions differ. Japanese typesetting uses patterns such as centered or distributed alignment depending on whether the annotation is shorter or longer than the base. Pick the value that matches the language you set.
  • Check the result. Browsers have only recently started to support the full set of values, so view the page in the browsers you target.

Browser support

Newer than ruby-position. Support differs between browsers and values, so check a compatibility table before relying on the exact distribution.