CSS scroll origin (source code)

= CSS scroll origin
{c}

The <CSS scroll origin> is the anchor coordinate from which a <CSS scroll container>'s scrollable overflow rectangle expands. Unless another rule specifies otherwise, the anchor is its block-start/inline-start corner. These are logical directions determined by the layout, so the origin need not be a physical upper-left corner.<CSS Overflow Module Level 3 by World Wide Web Consortium>[§2.3, scroll origin and default block-start/inline-start anchor]{ref}

Consider a $500$-by-$300$ <CSS pixel> content rectangle viewed through a $200$-by-$100$ <CSS scrollport>. Give the diagram physical coordinates increasing rightward and downward from the rectangle's top-left corner. Ignore transforms and scrollbar-size effects. In ordinary horizontal flow with inline-start on the left, aligning the origin with the corresponding scrollport corner exposes
$$
[0,200]\times[0,100].
$$
With inline-start on the right and block-start still at the top, origin alignment instead exposes
$$
[300,500]\times[0,100].
$$
Both views are at their respective scroll origin. The left edge of the second view has diagram coordinate $300$; this does not imply an API scroll offset of $300$.

A <CSS writing mode> helps determine which physical edges correspond to the logical starts. Other layout rules can supply different anchor conventions: the overflow draft gives a flex-container example using main-start/cross-start. The corner rule should therefore be read with its explicit exceptions, rather than imposed on every possible layout.<CSS Overflow Module Level 3 by World Wide Web Consortium>[§2.3, flex-container origin example and writing-mode dependence]{ref}

The <CSS initial scroll position> is another distinction. It usually agrees with origin alignment, but <CSS scroll snapping> can make the initial view differ. Returning to an origin and restoring an initial view are consequently not necessarily the same operation.<CSS Overflow Module Level 3 by World Wide Web Consortium>[§2.3, scroll-origin position versus initial scroll position and snapping example]{ref}

Numerical API offsets need their own conventions. The pinned overflow draft explicitly leaves the coordinate system for offsets unresolved, while <CSSOM View Module by World Wide Web Consortium> defines element scrolling operations and members such as `scrollLeft`. Interpret the <CSS scroll origin> geometrically first, then apply the particular interface's coordinate rules to compute a <CSS scroll position>.<CSS Overflow Module Level 3 by World Wide Web Consortium>[§2.3, coordinate-model issue]{ref}<CSSOM View Module by World Wide Web Consortium>[§6, Element scrolling members and algorithms]{ref}