Brifing

New CSS Gap Decorations Now Available

Styling gaps in grid and flexbox layouts just got much easier

CSS-Tricks2 min

1Revolutionary CSS Innovation

Web developers have long used border and pseudo-element hacks to style gaps in grid and flexbox layouts. With CSS gap decorations now fully supported in Chrome and Edge starting with version 149, styling gaps has become much easier and more controllable. Microsoft's Edge web platform team led both the design and standardization of this feature, marking a significant advancement in CSS capabilities for modern web layouts.

2Fundamentals of Gap Decorations

Gap decorations extend the column-rule CSS property, which already works in multi-column layouts, to function in grid and flexbox layouts as well. The introduction of row-rule property support enables decorations to appear on both axes. The syntax has been expanded to provide greater control over decorations. Property names have been refined for clarity based on developer feedback during early testing phases.

3Browser Support and Standardization

Gap decorations are currently available in Chrome and Edge version 149, as well as other Chromium-based browsers matching these versions. Other browser engines have shown interest in standards forums, suggesting the feature will become interoperable across all major browsers over time. Web developers' feedback during early testing played a crucial role in shaping the final implementation of this feature.

4Practical Usage Examples

Gap decorations can be used to add style between text and images in a wrapping flexbox container on a personal website's homepage. Both row-rule and column-rule properties allow decorations to be added to horizontal and vertical gaps. The new rule shorthand enables writing a single line of code when horizontal and vertical rules share the same values. The column-rule-inset property controls how rules meet at junctions.

5Advanced Grid Layout Techniques

In grid-based layouts like blog sections, gap decorations can be used when posts span multiple columns or rows. The rule-visibility-items property allows hiding lines next to empty grid cells, showing decorations only between cells with content. This creates a cleaner, more professional appearance. Three-column grid layouts can use 3rem gaps with aesthetic separator rules for visual organization.

6Auto-Adapting Section Dividers

Instead of fixed code like repeat(2, 2px solid #efefef) for sites with static sections, using repeat(auto, 2px solid #efefef) creates auto-adapting section dividers. When new sections are added to the site, the divider rules automatically adjust. Combining a 1rem thick main divider with 2px thick secondary dividers creates a hierarchical visual structure that scales with content.

7Flexbox Decoration Controls

In flexbox layouts, the column-rule-inset property's overlap-join value ensures adjacent rules join cleanly at intersections. This creates a more polished appearance where vertical rules meet horizontal ones. Decorations remain consistent across all gaps regardless of varying flex-basis values (like 12.5rem, 26.25rem, or 22.5rem). Two-pixel #999 rules work well between flex lines created with 3rem gaps.

8A New Era in Web Development

CSS gap decorations fundamentally transform gap management in modern web layouts. Developers can now create aesthetic gap decorations directly through CSS properties without complex hacks. This innovation particularly simplifies creating consistent visual separations in complex grid and flexbox layouts. As cross-browser support grows, these techniques are expected to become essential web standards.

Original article: CSS-Tricks — CSS'de Yeni Boşluk Dekorasyonları Kullanıma Sunuldu