W3cubDocs

/CSS

ruby-align

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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 value space-around
Applies to ruby bases, ruby annotations, ruby base containers, ruby annotation containers
Inherited yes
Media visual
Computed value as specified
Animation type discrete
Canonical order the 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>
  <rb>This is a long text to check</rb>
  <rp>(</rp><rt>short ruby</rt><rp>)</rp>
</ruby>
ruby {
  ruby-align:start;
}

This gives the following result:

Ruby aligned at the center of the base text

<ruby>
  <rb>This is a long text to check</rb>
  <rp>(</rp><rt>short ruby</rt><rp>)</rp>
</ruby>
ruby {
  ruby-align:center;
}

This gives the following result:

Extra space distributed between ruby elements

<ruby>
  <rb>This is a long text to check</rb>
  <rp>(</rp><rt>short ruby</rt><rp>)</rp>
</ruby>
ruby {
  ruby-align:space-between;
}

This gives the following result:

Extra space distributed between and around ruby elements

<ruby>
  <rb>This is a long text to check</rb>
  <rp>(</rp><rt>short ruby</rt><rp>)</rp>
</ruby>
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 Internet Explorer Opera Safari
Basic support No No1 38 No2 No No
Feature Android webview Chrome for Android Edge mobile Firefox for Android IE mobile Opera Android iOS Safari
Basic support No ? ? 38 No No No

1. Edge supports an earlier draft of CSS Ruby with non-standard values for this property: auto, left, center, right, distribute-letter, distribute-space, and line-edge.

2. Internet Explorer 9 and later supports an earlier draft of CSS Ruby with non-standard values for this property: auto, left, center, right, distribute-letter, distribute-space, and line-edge.

¹ 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

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/ruby-align