CKTIS / CSS
CSS property `ruby-align`
The inherited `ruby-align` property distributes extra space inside ruby bases, annotations, and their containers. `start` aligns content to the start edge, `center` centers it, while `space-between` and the initial `space-around` use justification opportunities.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
start | center | space-between | space-aroundThe inherited ruby-align property distributes extra space inside ruby bases, annotations, and their containers. start aligns content to the start edge, center centers it, while space-between and the initial space-around use justification opportunities.
The example compares start and center when a four-character annotation is wider than its one-character base. Both ruby boxes remain 22×30 pixels, but image samples put the black glyph at the first box’s edge and inward in the second.
Grammar: start | center | space-between | space-around.
With no justification opportunities, space-between centers the content; space-around adds one extra opportunity split half before and half after it. The property does not resize or reposition an ordinary ruby box; the CSS Ruby Editor’s Draft still evolves, so check @supports.
Examples
<!doctype html><meta charset="utf-8"><style>html,body{margin:0;background:white;font-family:monospace}.case{position:absolute;top:20px;font-size:20px;line-height:1;color:black}.case rb{display:ruby-base}.case rt{font-size:10px;color:blue}#start{left:0;ruby-align:start}#center{left:100px;ruby-align:center}</style><ruby id="start" class="case"><rb><span>█</span></rb><rt>WWWW</rt></ruby><ruby id="center" class="case"><rb><span>█</span></rb><rt>WWWW</rt></ruby><pre id="result"></pre><script>const a=getComputedStyle(start),b=getComputedStyle(center),g=e=>Math.round(e.getBoundingClientRect().width)+'x'+Math.round(e.getBoundingClientRect().height);if(a.rubyAlign!=='start'||b.rubyAlign!=='center'||g(start)!=='22x30'||g(center)!=='22x30')throw new Error('ruby mismatch');result.textContent='align='+a.rubyAlign+'/'+b.rubyAlign+'; boxes='+g(start)+'/'+g(center);</script>Result
align=start/center; boxes=22x30/22x30
The example compares `start` and `center` when a four-character annotation is wider than its one-character base. Both ruby boxes remain 22×30 pixels, but image samples put the black glyph at the first box’s edge and inward in the second.