Skip to content

[css-ruby-1] Clarify whether line-over ruby annotations on the first line can overflow the block container #14405

Open

Description

@tkent-google

Specification References

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:

  1. 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).
  2. If line-height and padding-top are 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.
  3. 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 when line-height / padding is 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

  1. fantasai commented on Aug 28, 2026

    @fantasai
    Collaborator

    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.

  2. tkent-google commented on Aug 28, 2026

    @tkent-google
    ContributorAuthor

    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.

    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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.css-ruby-1Current Workeditorial

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions