CSS Layout Properties: Display, Position, Flexbox and Grid (2026)

How display, position, flexbox and grid really behave, with six common layout bugs reproduced and measured in Chromium 141: fixed elements that scroll away, sticky headers that never stick, a z-index of 9999 that loses, and columns that refuse to share space.

DG
Derek Giordano
Designer & Developer

Display: Block, Inline, Flex and Grid

The display value decides how an element takes part in layout. Block elements start on a new line and take the full width; inline elements flow inside text and ignore width and height: we gave a <span> a width of 300 px and it rendered 37 px wide, the width of its text. inline-block flows like text but accepts a size; flex and grid turn an element into a layout container for its children.

Six Layout Gotchas, Measured

Most layout bugs come from a few rules that are easy to miss. We reproduced six in Chromium 141 and measured the result:

SetupWhat happenedFix
position: fixed inside a parent with transformAfter scrolling 500 px it sat at top -300 px and scrolled away; a normal fixed element stayed at 0A transform (also filter, perspective or contain) makes the parent the containing block; move the fixed element outside it
position: sticky inside an overflow: hidden ancestorScrolled to -100 px instead of sticking at 0 like the same element in a normal parentRemove the overflow on ancestors, or use overflow: clip, which does not create a scroll container
z-index: 9999 on a child of a parent with opacity: 0.99A sibling with z-index: 1 still covered itOpacity below 1 creates a stacking context; set the z-index on the parent instead
Width on an inline <span>Ignored (37 px instead of 300)Use display: inline-block or block
Grid 1fr 1fr 1fr with one long unbreakable wordColumns of 49 px / 503 px / 49 pxminmax(0, 1fr) plus overflow-wrap: anywhere gave 200 px / 200 px / 200 px
Two flex: 1 items, one holding a long nowrap labelWidths 8 px / 293 px: the label refused to shrinkmin-width: 0 (and an ellipsis) gave 150 px / 150 px

The last two share a cause: grid tracks sized with fr and flex items both default to a minimum size of "auto", meaning their content's minimum width, so one long word or URL can break an even layout. Setting that minimum to zero lets the space be shared as written.

The Five Position Values

Flexbox or Grid

Use flexbox for one direction at a time, such as a toolbar, a row of tags or a vertically centered card body, and grid when rows and columns both matter, such as page layouts, galleries and forms. They combine well: grid for the page, flex inside its cells. Both support gap. Try them hands-on in the Flexbox Playground and the Grid Generator; our CSS Grid guide goes deeper on grid.

Newer Layout Tools and Support

FeatureChromeFirefoxSafari
Flexbox gap846314.1
aspect-ratio888915
Container queries (@container)10511016
Subgrid1177116
Anchor positioning (anchor-name)12514726

Versions are from MDN's browser-compat-data 8.1.3; anchor positioning was rechecked live through the MDN connector on October 14, 2026, which lists Firefox 147 (January 2026) and Safari 26 (September 2025), so all three major engines now support it.

Browse all utility tools →
🔲
Try Border Radius Lab
Free, no signup →