CSS block flow direction
ID: css-block-flow-direction
The CSS block flow direction is the direction in which block-level boxes and successive line boxes progress in the relevant flow. The
writing-mode property determines this direction: horizontal-tb progresses top to bottom, vertical-rl right to left, and vertical-lr left to right.[ref]For an own geometry example, take three ordinary in-flow block boxes with zero margins, borders and padding, each having inline size and block size CSS pixels. Assume no conflicting sizing constraints and a containing region sized to fit them. In
horizontal-tb, the parent is pixels wide and high. The boxes occupy successive vertical intervals , and .In
vertical-rl, those same CSS logical dimensions give a parent pixels wide and high. Measuring physical from the left edge, the first box occupies , the second and the third . Their source order is unchanged, but the block progression runs toward decreasing physical . These are stipulated box geometries, not font-dependent text measurements.[ref]CSS Writing Modes Level 4 by World Wide Web Consortium. §6.1, logical dimensions; §6.4, abstract-to-physical mappings
CSS inline direction concerns progression within a line and its base directionality. Setting
direction: rtl in an otherwise horizontal example does not make the block stack run upward: writing-mode still supplies its top-to-bottom block flow. Likewise, the rl in vertical-rl describes block progression rather than simply naming right-to-left text ordering.This distinction also affects CSS scroll origin, whose default anchor uses block-start and inline-start. In the horizontal example, block-start is top; in the vertical right-to-left block flow it is right. Rules expressed using logical starts and sizes can therefore follow the layout convention instead of hard-coding one physical edge.[ref]
CSS Writing Modes Level 4 by World Wide Web Consortium. §6.2, Flow-relative Directions; §6.4, mappings
New to topics? Read the docs here!