Repository navigation
[css-ruby-1] Clarify whether line-over ruby annotations on the first line can overflow the block container #14405
Description
Specification References
- CSS Ruby Layout Module Level 1 — § 3.6 Line Spacing
- CSS Inline Layout Module Level 3 — § 2.1 Establishing Inline Layout
- CSS 2.1 / 2.2 — § 9.4.2 Inline formatting contexts
Background & Current Specification Behavior
According to css-ruby-1 § 3.6:
"However, if the line-height specified on the ruby container is less than the distance between the top of the top ruby annotation container and the bottom of the bottom ruby annotation container, then additional leading is added on the appropriate side(s) of the ruby base container such that if a block consisted of three lines each containing ruby identical to this, none of the ruby containers would overlap.
Note: This does not ensure that the ruby annotations remain within the line box. It merely ensures that if all lines had equal spacing and equivalent amounts and positioning of ruby annotations, there would be enough room to avoid overlap.
Authors should ensure appropriate line-height and padding to accommodate ruby, and be particularly careful at the beginning or end of a block..."
Furthermore, css-inline-3 § 2.1 (and CSS2 § 9.4.2) specifies:
"Line boxes are stacked as the direct contents of the block container box in its block flow direction... Line boxes are stacked with no separation (except as specified elsewhere, e.g. for float clearance) and they never overlap."
The Ambiguity & Current Inconsistency
Reading these specifications together suggests the following behavior:
- The first line box in an IFC has its top edge placed flush against the top content edge of the containing block (with no vertical separation).
- If
line-heightandpadding-topare small (e.g.<div style="line-height: 1; padding: 0"><ruby>base<rt>anno</rt></ruby></div>), the line-over<rt>extends above the line box. - Therefore, the
<rt>on the first line will overflow the top content/padding boundary of the block container as ink overflow.
However, the specification is not entirely explicit on whether this block-level overflow is the intended normative behavior, leading to diverging implementations across browser engines:
- Chromium: The first line's
<rt>can overflow the block container's top boundary whenline-height/paddingis insufficient. - Gecko (Firefox) / WebKit (Safari): Appear to prevent the ruby annotation from overflowing the top of the block container (e.g., expanding the line box or shifting the line position downward).
Rationale for Allowing Overflow (Consistency Across Layouts)
From a Japanese typography / native speaker's perspective, allowing <rt> to overflow the block container's top boundary feels like the more desirable and consistent behavior.
Consider the following two markup structures:
Case A (Single Block with line break):
<div style="line-height: 1.5;">
foo<br>
<ruby>base<rt>annotation</rt></ruby>
</div>Case B (Split into two Blocks):
<div style="line-height: 1.5;">foo</div>
<div style="line-height: 1.5;"><ruby>base<rt>annotation</rt></ruby></div>If engines prevent <rt> from overflowing the block container in Case B by automatically pushing the second line downward (or expanding the block's top), the vertical distance between "foo" and "base" in Case B becomes significantly different from Case A.
Allowing <rt> to consistently overflow the line box/block boundary preserves uniform baseline grid / line spacing regardless of whether the content is broken across <br> or split into separate <div> blocks.
Proposal
- Could we clarify whether line-over ruby annotations on the first line are normatively expected to overflow the block container's top boundary when padding-top is 0?
Activity
fantasai commentedon Aug 28, 2026
It was indeed intended to overflow, for exactly the reasons you state. I don't think the spec is ambiguous on this point, either, though perhaps it would benefit from an example to show that this was intended behavior.
tkent-google commentedon Aug 28, 2026
Thank you for the reply. Yeah, an example would be helpful.
Also, I wonder if UAs should avoid overflow in some cases. e.g. borders and
contain: paint(new formatting context?)