CSS scroll margin 2026-11-05
CSS scroll margin supplies outsets around an element's transformed border bounds to define its CSS scroll snap area. The
scroll-margin shorthand assigns top, right, bottom and left values using the usual one-to-four-value ordering. In the pinned specification these values are lengths, rather than percentages.[ref]CSS Scroll Snap Module Level 1 by World Wide Web Consortium. §5.1, scroll-margin syntax, ordering and area construction
For an own example, let an untransformed CSS border box occupy in content coordinates measured in CSS pixels. Set
scroll-margin: 20px 10px;. The first value applies at top and bottom, and the second at left and right, giving the snap areaThe box itself is still by pixels; the alignment region is by .Suppose a reachable horizontal start alignment should place this area's left edge at coordinate within the CSS snapport. With a left-to-right horizontal convention, the candidate offset satisfies , giving . Without the left outset, it would instead be . The extra target-side room changes the alignment computation without changing where the border is laid out in the content.
The construction uses the axis-aligned bounding box of the transformed border box before adding the outsets. A rotated CSS transform can therefore affect the base rectangle, even though the resulting snap area remains rectangular in the scroll container's coordinates.[ref]
CSS Scroll Snap Module Level 1 by World Wide Web Consortium. §5.1, transformed bounds and axis alignment
CSS scroll margin and ordinary layout margins serve different purposes. The former does not assign this extra space between neighboring elements in normal layout. It is also distinct from CSS scroll padding, which adjusts the viewing/alignment region on the container side.
CSS scroll snap area 2026-11-05
A CSS scroll snap area is the target region aligned within a CSS snapport during CSS scroll snapping. The specification constructs it from the target's transformed CSS border box: find its rectangular bounding box, aligned to the scroll container's coordinate axes, then apply the outsets supplied by CSS scroll margin.[ref]
CSS Scroll Snap Module Level 1 by World Wide Web Consortium. §5.1, scroll-margin and snap-area construction
Consider an untransformed element whose border box occupiesin content coordinates measured in CSS pixels. Set
scroll-margin: 10px 20px 30px 40px;, in top/right/bottom/left order. The snap area becomesIt is pixels wide and high, even though the original border box remains by .For a candidate start alignment, suppose the CSS snapport begins at viewport coordinates and is large enough to contain this area. Use a horizontal left-to-right writing mode and assume adequate reachable scroll ranges. The required offsets satisfygiving . At that position, the element's actual border box appears at ; the extra room comes from aligning the larger snap area, not moving its borders relative to its content.[ref]
CSS Scroll Snap Module Level 1 by World Wide Web Consortium. §5.2, start alignment of snap area within snapport
A CSS transform can change the initial bounding rectangle. The snap area is nevertheless axis-aligned in the scroll container's coordinate space, even if the transformed border is rotated. Its rectangular shape is therefore an alignment construction, not necessarily the painted outline of the element.
CSS scroll margin also differs from an ordinary layout margin: the example's outsets enlarge the snapping region without assigning extra space between neighboring boxes in normal layout. Reachability and visibility still constrain valid snap positions. If an exact alignment would require scrolling beyond the available area, the specification uses the reachable position as far toward that alignment as possible.[ref]
CSS Scroll Snap Module Level 1 by World Wide Web Consortium. §5.1, outsets; §§5.2.1 and 5.2.3, valid visibility and unreachable positions
CSS transform 2026-11-05
A CSS transform changes the coordinate mapping used to render a transformable element. Translation, scaling and rotation are examples of CSS transform functions. Their composition maps local points into the parent coordinate system; the CSS transform origin specifies the point around which the transformation is constructed.[ref]
CSS Transforms Module Level 1 by World Wide Web Consortium. §3, Transform Rendering Model; §§4–5, transform and transform-origin
For an own two-dimensional example, use an ordinary CSS box with
transform-box: border-box; transform-origin: 0 0;, no ancestor transforms, and local coordinates relative to that top-left origin. This fixes the CSS transform reference box and origin explicitly. Ignore the box's placement offset to isolate the transform itself.Using homogeneous column vectors, letThe list
transform: translate(10px, 0) scale(2); gives the product . Applied to point , the scale acts first:Reversing the list to scale(2) translate(10px, 0) gives and the result . The translation is scaled in the reversed composition. Matrix multiplication explains the order dependence.[ref]CSS Transforms Module Level 1 by World Wide Web Consortium. §3, matrix construction and local-to-parent mapping; §9.1, 2D functions
The zero origin is part of the example, not an irrelevant decoration. A different origin adds translations around the listed operations and can change the mapped point. The simple matrix computation also fixes its column-vector convention instead of relying on an ambiguous phrase such as applying functions in order.
For boxes governed by the CSS box model, a transform changes rendering without rearranging the surrounding normal-flow content. It can nevertheless extend CSS overflow, and transformed geometry affects client rectangles. The absence of normal-flow re-layout is therefore not a claim that every geometrical or scrolling quantity stays fixed.[ref]
CSS Transforms Module Level 1 by World Wide Web Consortium. §3, surrounding flow, overflow and client-rectangle effects
The same transformed bounds matter when constructing a CSS scroll snap area. A rendered border can be rotated while its axis-aligned bounding box is used for alignment geometry. Separating layout boxes, coordinate mappings and derived bounds makes these effects easier to calculate.
CSS transform function 2026-11-05
A CSS transform function specifies one coordinate mapping in a CSS transform list. Functions such as
translate(), scale(), rotate() and matrix() have defined argument types and geometrical meanings. The list is composed by matrix multiplication, with the CSS transform origin supplying the surrounding origin translations.[ref]CSS Transforms Module Level 1 by World Wide Web Consortium. §9.1, 2D transform functions; §§3 and 10, composition
For the two-dimensional function
matrix(a,b,c,d,e,f), a homogeneous column-vector convention givesIn particular, and . The six arguments do not fill the displayed matrix row by row.[ref]For an own example with zero origin,
matrix(2,0,0,3,10,-5) maps point toThis combines horizontal scaling by two, vertical scaling by three and a translation. The arguments and coordinates are chosen to isolate the mapping, not to measure a browser's glyph rendering.Order matters when composing functions. With zero origin,
translate(10px,0) scale(2) maps to , while scale(2) translate(10px,0) maps it to . In column-vector form, the first matrix product is and the second ; the translation itself is scaled in the latter.[ref]CSS Transforms Module Level 1 by World Wide Web Consortium. §3, function-list matrix construction; §10, transform lists
The CSS transform reference box is also part of interpreting arguments that use percentages. A function's spelling alone does not determine every resulting coordinate without its lengths, percentage bases, origin and ancestor mappings. The reusable mathematical description is an ordered coordinate transformation with those inputs stated explicitly.
CSS transform origin 2026-11-05
The CSS transform origin is the point used when constructing an element's CSS transform matrix. The construction translates by the origin, applies the CSS transform functions, then translates by the negated origin. With homogeneous column vectors, its form iswhere is the matrix product for the function list and translates by the origin .[ref]
CSS Transforms Module Level 1 by World Wide Web Consortium. §3, matrix-construction steps
For an own example, use an ordinary CSS box with a -by--pixel border box,
transform-box: border-box, and no ancestor transforms. The declaration transform-origin: 50% 50% gives in local coordinates. With transform: scale(2), a point maps toThus maps to . The same point scaled about would instead map to .The corresponding two-dimensional homogeneous matrix isIt maps the original corner to while leaving the center fixed. Changing the origin therefore changes the geometry even though the scale function is unchanged.
Percentages require a CSS transform reference box. A horizontal origin percentage uses that box's width and a vertical percentage its height; lengths provide offsets from its top-left corner. The reference-box selection and the point specified within it are two separate inputs.[ref]
CSS Transforms Module Level 1 by World Wide Web Consortium. §5, percentage/length offsets; §6, transform reference box
The example explicitly chooses its box and origin instead of transferring defaults between ordinary CSS boxes and SVG elements. The transform origin is also distinct from the CSS scroll origin, which concerns the alignment of scrollable contents. One governs coordinate transformation; the other anchors scrolling geometry.
CSS transform reference box 2026-11-05
The CSS transform reference box supplies the geometrical reference used to interpret a CSS transform and its CSS transform origin. The
transform-box property selects that reference. Its size supplies percentage bases, and its position can add an offset to the specified origin.[ref]CSS Transforms Module Level 1 by World Wide Web Consortium. §6, Transform reference box: transform-box
For an own ordinary-box example, use a -by- CSS pixel content box, zero borders, twenty pixels of left padding, ten of top padding and zero padding on the other sides. Assume the content dimensions are definite and unaffected by competing constraints. The CSS border box is by , while the CSS content box begins at border-box coordinates .
With
transform-box: border-box, a transform-origin: 50% 50% point is in those coordinates. With transform-box: content-box, the same percentage declaration instead givesThe difference comes from both the reference size and its offset. Asymmetric padding makes that distinction visible; two centered symmetric boxes could conceal it.The function
translateX(50%) likewise uses the selected reference width. Its translation component is sixty pixels for the border-box choice and fifty for the content-box choice. Percentage translation and percentage origin therefore require a stated reference rectangle before they can be converted into lengths.[ref]CSS Transforms Module Level 1 by World Wide Web Consortium. §6, reference-box use by transforms and origin; §9.1, percentage translation
The property has additional reference choices for SVG, including object bounds and viewport-based geometry. Their used-value mappings differ depending on whether an SVG element has an associated CSS layout box. The ordinary-box example does not establish a universal default for every SVG element.[ref]
CSS Transforms Module Level 1 by World Wide Web Consortium. §6, fill-box, stroke-box, view-box and used-value mappings
Reference-box selection does not itself assign a new content width or padding. It tells the transformation calculation which existing rectangle to use. Keeping it separate from layout sizing and from the chosen origin prevents two distinct percentage bases from being conflated.
CSS typographic mode 2026-11-05
The CSS typographic mode determines whether text uses typographic conventions specific to vertical flow or is treated as horizontal typography. This distinction is separate from the orientation of the CSS writing mode: text can occupy a vertical flow while retaining horizontal typographic treatment.[ref]
CSS Writing Modes Level 4 by World Wide Web Consortium. §1, typographic mode definition; §3.2, writing-mode values
Under
writing-mode: horizontal-tb, both writing mode and typographic mode are horizontal. Under vertical-rl or vertical-lr, both are vertical. Under sideways-rl or sideways-lr, the writing mode is vertical but the typographic mode is horizontal. Thus the suffix that names block progression does not by itself identify the typographic conventions.[ref]CSS Writing Modes Level 4 by World Wide Web Consortium. §3.2, mode classification for each writing-mode value
For an illustrative token
漢A, compare vertical-rl with text-orientation: mixed against sideways-rl. In the first case, the vertical-script glyph receives its intrinsic vertical orientation while the Latin letter is sideways. The second mode treats the run as horizontal typography presented sideways. Both have right-to-left CSS block flow direction, but they need not produce the same glyph treatment.[ref]CSS Writing Modes Level 4 by World Wide Web Consortium. §3.2, sideways mode; §5.1, mixed orientation
This distinction matters for font selection of vertical glyphs, orientation and alignment. Vertical typesetting can use vertical metrics and alternate glyph forms rather than simply rotate all horizontal outlines. The example describes the specified categories, not an exact pixel measurement for every font.[ref]
CSS Writing Modes Level 4 by World Wide Web Consortium. §5.1.1, Vertical Typesetting and Font Features
CSS glyph orientation is another related layer of control. In the pinned specification,
text-orientation has an effect only in vertical typographic modes; setting it on a box using horizontal typographic mode does not turn that mode into vertical typography.[ref]CSS Writing Modes Level 4 by World Wide Web Consortium. §5.1, applicability of text-orientation
Keep CSS inline direction, block progression and typographic treatment distinct when diagnosing a vertical label. A change in the visible arrangement can come from different stages of the layout and text shaping process, so a single whole-box CSS transform is not a general substitute for specifying the intended typography.