Skip to content

[css-position-3][css-align-3] Handling center alignment for abspos boxes with auto/normal self-alignment and center item alignment in parent #12542

Open

Description

@sammygill
<div style="position: relative;">
    <div style="display: grid; align-items: center; width: 22px; height: 30px; border: 1px solid blue;">
        <div style="position: absolute; background-color: green; width: 8px; height: 6px;"></div>
    </div>
</div>

In the above example, Gecko and Blink both center align the box vertically within the grid's content box, which seems reasonable to me. However, I was trying to find some spec text which explains how this exactly occurs to rationalize it but was struggling to find something. According to my current reading, what it looks like should be occurring is something along the lines of:

1.) Compute the insets for the containing block with the rules for center alignment described in https://www.w3.org/TR/css-position-3/#resolving-insets. I believe this just ends up being 0 for both inset values.

Note: We refer to the parent's align-items value because of https://drafts.csswg.org/css-align-3/#align-self-property

2.) After sizing the box, we need to align it within its alignment container. Again referring to https://drafts.csswg.org/css-align-3/#align-self-property since we are computing the actual position of the box, this should behave as normal. However, https://drafts.csswg.org/css-align-3/#align-abspos seems to state that the normal behavior should either be start or stretch for the box (start in this case, I think).

I assume the intention is for the box to be center aligned, but it seems to be a bit at odds with the current state of the spec. Should the normal behavior of an abspos box be adjusted in this case to take this into consideration? Or perhaps are Gecko and Blink referring to a different part of the spec that results in this rendering?

Activity

  1. moved this to Thursday Breakout (1pm?) in CSSWG August 2025 meeting agendaon Aug 18, 2025
  2. added
    Agenda+ Whiteboard
    on Aug 21, 2025
  3. css-meeting-bot commented on Aug 21, 2025

    @css-meeting-bot
    Member

    The Houdini Task Force just discussed [css-position-3][css-align-3] Handling center alignment for abspos boxes with auto/normal self-alignment and center item alignment in parent, and agreed to the following:

    • RESOLVED: in a statically positioned axis, normal self-alignment *does* take from the parent's justify/align-items property
    The full IRC log of that discussion <alisonmaher> TabAtkins: this is the exact question we resolved on
    <alisonmaher> fantasai: that was just the axis
    <alisonmaher> 2
    <alisonmaher> TabAtkins: we have align self on abspos. The normal keyword always resolves to stretch and start not align items. Need static pos exception
    <alisonmaher> ...behavior of normal keyword needs to look at parent align items or justify when calculating static pos in this case
    <alisonmaher> iank_: yes
    <alisonmaher> iank_: have compat on flex for this
    <alisonmaher> TabAtkins: grid also works that way
    <alisonmaher> iank_: sgtm
    <alisonmaher> ...align items of parent not CB
    <alisonmaher> oriol: wondering if it was web compat to do in general
    <fantasai> PROPOSED: in a statically positioned axis, normal self-alignment *does* take from the parent's justify/align-items property
    <alisonmaher> ...probably not matching in servo
    <fantasai> RESOLVED: in a statically positioned axis, normal self-alignment *does* take from the parent's justify/align-items property
  4. removed
    Agenda+ Whiteboard
    on Aug 21, 2025
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 Accepted by CSSWG ResolutionNeeds Editscss-align-3css-position-3

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions