MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The ruby-align CSS property defines the distribution of the different ruby elements over the base.

/* Keyword values */
ruby-align: start;
ruby-align: center;
ruby-align: space-between;
ruby-align: space-around;

/* Global values */
ruby-align: inherit;
ruby-align: initial;
ruby-align: unset;

Initial valuespace-around
Applies toruby bases, ruby annotations, ruby base containers, ruby annotation containers
Inheritedyes
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

Values

start
Is a keyword indicating that the ruby will be aligned with the start of the base text.
center
Is a keyword indicating that the ruby will be aligned at the middle of the base text
space-between
Is a keyword indicating that the extra space will be distributed between the elements of the ruby.
space-around
Is a keyword indicating that the extra space will be distributed between the elements of the ruby, and around it.

Formal syntax

start | center | space-between | space-around

Examples

This HTML will render differently with each value of ruby-align:

<ruby>
  <rb>This is a long text to check</rb>
  <rp>(</rp><rt>short ruby</rt><rp>)</rp>
</ruby>

Ruby aligned at the start of the base text

ruby {
  ruby-align:start;
}

This gives the following result:

Ruby aligned at the center of the base text

ruby {
  ruby-align:center;
}

This gives the following result:

Extra space distributed between ruby elements

ruby {
  ruby-align:space-between;
}

This gives the following result:

Extra space distributed between and around ruby elements

ruby {
  ruby-align:space-around;
}

This gives the following result:

Specifications

Specification Status Comment
CSS Ruby Layout Module Level 1
The definition of 'ruby-align' in that specification.
Working Draft Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support No support No support¹ 38 (38) No support¹ No support No support
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support No support (Yes) 38.0 (38) No support¹ No support No support

¹ Microsoft Edge and its predecessor Internet Explorer—versions 9 through 11—implement an early draft of CSS Ruby where the ruby-align property had the values auto, left, center, right, distribute-letter, distribute-space, and line-edge. Here is a table describing approximate equivalency between the Microsoft implementations and the current CSS Ruby, Level 1 specification:

Edge and IE Syntax Standard Syntax
auto space-around (default value) for ideographic scripts or center for Latin scripts; to achieve a similar effect, one may use ISO 15924 script codes in conjunction with HTML lang attributes or XML xml:lang attributes and CSS lang pseudo‑class selectors
left start in left‐to‐right scripts
center center without the optional behavior described in CSS Ruby, Level 1, Section 5.2: Line‐Edge Alignment; this is the Firefox behavior
right start in right‐to‐left scripts
distribute-letter space-between
distribute-space space-around (default value)
line-edge center with the optional behavior described in CSS Ruby, Level 1, Section 5.2: Line‐Edge Alignment; Firefox does not support a keyword for this behavior; CSS rules targeting individual ruby elements with the center and start keywords based on ruby base text positions and widths may be used instead to achieve similar effects in Firefox

See also

Document Tags and Contributors

 Last updated by: chrisdavidmills,