CSS Gap Decorations Module Level 1

Unofficial Proposal Draft,

More details about this document
This version:
https://kbabbitt.github.io/css-gap-decorations/
Issue Tracking:
CSSWG Issues Repository
Editor:
Kevin Babbitt (Microsoft)
Suggest an Edit for this Spec:
GitHub Editor

Abstract

This module introduces several properties to add row and column gap decorations to container layout types such as grid and flex.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

Status of this document

This section describes the status of this document at the time of its publication. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

Please send feedback by filing issues in GitHub (preferred), including the spec code “css-gap-decoration” in the title, like this: “[css-gap-decoration] …summary of comment…”. All issues and comments are archived. Alternately, feedback can be sent to the (archived) public mailing list www-style@w3.org.

This document is governed by the 03 November 2023 W3C Process Document.

This document was produced by a group operating under the W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

1. Introduction

This section is not normative.

CSS Multicol 1 § 4 Column Gaps and Rules allows for rules to be drawn between columns in a multicol container. This specification expands upon the column-rule-width, column-rule-style, and column-rule-color properties, adding equivalents in the row direction, expanding their application to other container layouts, and giving advanced control over where and how gap decorations are painted.

1.1. Value Definitions

This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3]. Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3]. Combination with other CSS modules may expand the definitions of these value types.

In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the CSS-wide keywords as their property value. For readability they have not been repeated explicitly.

2. Defining gap decoration areas

2.1. Grid gap decoration areas: The grid-column-rule-area and grid-row-rule-area properties

Name: grid-column-rule-area, grid-row-rule-area
Value: [ <grid-line> [ / <grid-line> ]{0,3} ]#
Initial: 1 / 1 / -1 / -1
Applies to: grid containers
Inherited: no
Percentages: n/a
Computed value: specified value
Canonical order: per grammar
Animation type: not animatable

A list of grid line tuples, as in the grid-area property, that define portions of the grid over which gap decorations are painted.

3. Color, style, and width

3.1. Gap decoration color: The column-rule-color and row-rule-color properties

Name: column-rule-color, row-rule-color
Value: [ <line-color-list> | <auto-line-color-list> ]#
Initial: curerentcolor
Applies to: grid containers, flex containers, multicol containers, and masonry containers
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: by computed value type
<line-color-list>          = [ <line-color-or-repeat> ]+

<auto-line-color-list>     = [ <line-color-or-repeat> ]*
                             <auto-repeat-line-color>
                             [ <line-color-or-repeat> ]*

<line-color-or-repeat>     = [ <color> | <repeat-line-color> ]

<repeat-line-color>        = repeat( [ <integer [1,∞]> ] , [ <color> ]+ )

<auto-repeat-line-color>   = repeat( auto , [ <color> ]+ )

3.2. Gap decoration style: The column-rule-style and row-rule-style properties

Name: column-rule-style, row-rule-style
Value: [ <line-style-list> | <auto-line-style-list> ]#
Initial: none
Applies to: grid containers, flex containers, multicol containers, and masonry containers
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: discrete
<line-style-list>          = [ <line-style-or-repeat> ]+

<auto-line-style-list>     = [ <line-style-or-repeat> ]*
                             <auto-repeat-line-style>
                             [ <line-style-or-repeat> ]*

<line-style-or-repeat>     = [ <line-style> | <repeat-line-style> ]

<repeat-line-style>        = repeat( [ <integer [1,∞]> ] , [ <line-style> ]+ )

<auto-repeat-line-style>   = repeat( auto , [ <line-style> ]+ )

3.3. Gap decoration width: The column-rule-width and row-rule-width properties

Name: column-rule-width, row-rule-width
Value: [ <line-width-list> | <auto-line-width-list> ]#
Initial: medium
Applies to: grid containers, flex containers, multicol containers, and masonry containers
Inherited: no
Percentages: n/a
Computed value: absolute length, snapped as a border width; 0 if the rule style is none or hidden
Canonical order: per grammar
Animation type: by computed value type
<line-width-list>          = [ <line-width-or-repeat> ]+

<auto-line-width-list>     = [ <line-width-or-repeat> ]*
                             <auto-repeat-line-width>
                             [ <line-width-or-repeat> ]*

<line-width-or-repeat>     = [ <line-width> | <repeat-line-width> ]

<repeat-line-width>        = repeat( [ <integer [1,∞]> ] , [ <line-width> ]+ )

<auto-repeat-line-width>   = repeat( auto , [ <line-width> ]+ )

3.4. Gap decoration shorthands: The column-rule and row-rule properties

Name: column-rule, row-rule
Value: [ <gap-rule-list> | <auto-gap-rule-list> ]#
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar
<gap-rule-list>        = <gap-rule-or-repeat> [ / <gap-rule-or-repeat> ]*

<auto-gap-rule-list>   = [ [ <gap-rule-or-repeat> ] / ]*
                         <auto-repeat-gap-rule>
                         [ / [ <gap-rule-or-repeat> ] ]*

<gap-rule-or-repeat>   = [ <gap-rule> | <repeat-gap-rule> ]

<repeat-gap-rule>      = repeat( [ <integer [1,∞]> ] , [ <gap-rule> ]# )

<auto-repeat-gap-rule> = repeat( auto , [ <gap-rule> ]# )

<gap-rule>             = [ <line-width> || <line-style> || <color> ]

3.5. Bi-directional gap decoration shorthands: The gap-rule-color, gap-rule-style, and gap-rule-width properties

Name: gap-rule-color
Value: <'column-rule-color'>
Initial: see individual properties
Applies to: Same as column-rule-color and row-rule-color
Inherited: no
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar
Name: gap-rule-style
Value: <'column-rule-style'>
Initial: see individual properties
Applies to: Same as column-rule-style and row-rule-style
Inherited: no
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar
Name: gap-rule-width
Value: <'column-rule-width'>
Initial: see individual properties
Applies to: Same as column-rule-width and row-rule-width
Inherited: no
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

4. Gap decoration segment painting

By default, gap decorations are painted as continuous segments that extend as far as possible along the centerline of a given gap. The decoration is painted from one gap T intersection to another, with both endpoints at the centers of the T crossings and the decoration proceeding along the stems of both Ts. In grid layout, row decorations are painted on top of column decorations by default; this behavior may be changed using the gap-rule-paint-order property.

4.1. Gap decoration segment length: The column-rule-outset and row-rule-outset properties

Authors may specify that decorations are instead segmented between all gap intersections. In such cases, each segment starts at the edge of a given gap intersection and proceeds to the edge of the next gap intersection. The endpoints may be offset from those endpoints using the column-rule-outset and row-rule-outset properties.

Name: column-rule-outset, row-rule-outset
Value: [ <length-percentage> | join ]#
Initial: join
Applies to: grid containers, flex containers, multicol containers, and masonry containers
Inherited: no
Percentages: refer to the gap width in the perpendicular direction
Computed value: as specified
Canonical order: per grammar
Animation type: by computed value type
join
"Joins together" segments to give the "T intersections" behavior described above. To facilitate animation effects, join computes to 50%.
<length-percentage>
Each segment starts at the edge of a given gap intersection and proceeds to the edge of the next gap intersection, modified by the value given. Positive values extend into the neighboring intersection; negative values recede from it. These offsets also apply at the edges of the container, where negative values may extend into the padding area.

4.2. Interaction with spanning items in Grid: The grid-column-rule-break, grid-row-rule-break, and grid-rule-break properties

Name: grid-column-rule-break, grid-row-rule-break
Value: [ span | none ]#
Initial: span
Applies to: grid containers
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: discrete
span
Gives either the "T intersections" or "all intersections" behavior described previously, depending on the value of the column-rule-outset or row-rule-outset property.
none
Causes gap decorations to cross behind spanning items and receive the "T intersection" behavior described previously at the edges of the gap decoration area.
Name: grid-rule-break
Value: [ span | none ]#
Initial: see individual properties
Applies to: Same as grid-column-rule-break and grid-row-rule-break
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

4.3. Gap decoration paint order: The gap-rule-paint-order property

Name: gap-rule-paint-order
Value: [ row-over-column | column-over-row | main-over-cross | cross-over-main ]#
Initial: main-over-cross
Applies to: grid containers, flex containers, multicol containers, and masonry containers
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: discrete

5. Direction-relative properties

These are designed to enable scenarios where authors wish to switch flex-direction based on space constraints or other factors.

5.1. Direction-relative decoration colors: The main-rule-color and cross-rule-color properties

Name: main-rule-color, cross-rule-color
Value: <'column-rule-color'>
Initial: curerentcolor
Applies to: Same as column-rule-color and row-rule-color
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: by computed value type

5.2. Direction-relative decoration styles: The main-rule-style and cross-rule-style properties

Name: main-rule-style, cross-rule-style
Value: <'column-rule-style'>
Initial: none
Applies to: Same as column-rule-style and row-rule-style
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: discrete

5.3. Direction-relative decoration width: The main-rule-width and cross-rule-width properties

Name: main-rule-width, cross-rule-width
Value: <'column-rule-width'>
Initial: medium
Applies to: Same as column-rule-width and row-rule-width
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: by computed value type

5.4. Direction-relative decoration shorthands: The main-rule and cross-rule properties

Name: main-rule, cross-rule
Value: <'column-rule'>
Initial: see individual properties
Applies to: Same as column-rule and row-rule
Inherited: see individual properties
Percentages: see individual properties
Computed value: see individual properties
Animation type: see individual properties
Canonical order: per grammar

5.5. Direction-relative segment lengths: The main-rule-outset and cross-rule-outset properties

Name: main-rule-outset, cross-rule-outset
Value: <'column-rule-outset'>
Initial: join
Applies to: Same as column-rule-outset and row-rule-outset
Inherited: no
Percentages: n/a
Computed value: as specified
Canonical order: per grammar
Animation type: by computed value type

Privacy Considerations

No new privacy considerations have been reported on this specification.

Security Considerations

No new security considerations have been reported on this specification.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Partial implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

Non-experimental implementations

Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-BACKGROUNDS-3]
Elika Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. URL: https://drafts.csswg.org/css-backgrounds/
[CSS-COLOR-5]
Chris Lilley; et al. CSS Color Module Level 5. URL: https://drafts.csswg.org/css-color-5/
[CSS-FLEXBOX-1]
Tab Atkins Jr.; et al. CSS Flexible Box Layout Module Level 1. URL: https://drafts.csswg.org/css-flexbox-1/
[CSS-GRID-2]
Tab Atkins Jr.; Elika Etemad; Rossen Atanassov. CSS Grid Layout Module Level 2. URL: https://drafts.csswg.org/css-grid-2/
[CSS-MULTICOL-1]
Florian Rivoal; Rachel Andrew. CSS Multi-column Layout Module Level 1. URL: https://drafts.csswg.org/css-multicol/
[CSS-VALUES-3]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. URL: https://drafts.csswg.org/css-values-3/
[CSS-VALUES-4]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. URL: https://drafts.csswg.org/css-values-4/
[CSS2]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. URL: https://drafts.csswg.org/css2/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://datatracker.ietf.org/doc/html/rfc2119

Property Index

Name Value Initial Applies to Inh. %ages Anim­ation type Canonical order Com­puted value
column-rule [ <gap-rule-list> | <auto-gap-rule-list> ]# see individual properties see individual properties see individual properties see individual properties see individual properties per grammar see individual properties
column-rule-color [ <line-color-list> | <auto-line-color-list> ]# curerentcolor grid containers, flex containers, multicol containers, and masonry containers no n/a by computed value type per grammar as specified
column-rule-outset [ <length-percentage> | join ]# join grid containers, flex containers, multicol containers, and masonry containers no refer to the gap width in the perpendicular direction by computed value type per grammar as specified
column-rule-style [ <line-style-list> | <auto-line-style-list> ]# none grid containers, flex containers, multicol containers, and masonry containers no n/a discrete per grammar as specified
column-rule-width [ <line-width-list> | <auto-line-width-list> ]# medium grid containers, flex containers, multicol containers, and masonry containers no n/a by computed value type per grammar absolute length, snapped as a border width; 0 if the rule style is none or hidden
cross-rule <'column-rule'> see individual properties Same as column-rule and row-rule see individual properties see individual properties see individual properties per grammar see individual properties
cross-rule-color <'column-rule-color'> curerentcolor Same as column-rule-color and row-rule-color no n/a by computed value type per grammar as specified
cross-rule-outset <'column-rule-outset'> join Same as column-rule-outset and row-rule-outset no n/a by computed value type per grammar as specified
cross-rule-style <'column-rule-style'> none Same as column-rule-style and row-rule-style no n/a discrete per grammar as specified
cross-rule-width <'column-rule-width'> medium Same as column-rule-width and row-rule-width no n/a by computed value type per grammar as specified
gap-rule-color <'column-rule-color'> see individual properties Same as column-rule-color and row-rule-color no see individual properties see individual properties per grammar see individual properties
gap-rule-paint-order [ row-over-column | column-over-row | main-over-cross | cross-over-main ]# main-over-cross grid containers, flex containers, multicol containers, and masonry containers no n/a discrete per grammar as specified
gap-rule-style <'column-rule-style'> see individual properties Same as column-rule-style and row-rule-style no see individual properties see individual properties per grammar see individual properties
gap-rule-width <'column-rule-width'> see individual properties Same as column-rule-width and row-rule-width no see individual properties see individual properties per grammar see individual properties
grid-column-rule-area [ <grid-line> [ / <grid-line> ]{0,3} ]# 1 / 1 / -1 / -1 grid containers no n/a not animatable per grammar specified value
grid-column-rule-break [ span | none ]# span grid containers no n/a discrete per grammar as specified
grid-row-rule-area [ <grid-line> [ / <grid-line> ]{0,3} ]# 1 / 1 / -1 / -1 grid containers no n/a not animatable per grammar specified value
grid-row-rule-break [ span | none ]# span grid containers no n/a discrete per grammar as specified
grid-rule-break [ span | none ]# see individual properties Same as grid-column-rule-break and grid-row-rule-break see individual properties see individual properties see individual properties per grammar see individual properties
main-rule <'column-rule'> see individual properties Same as column-rule and row-rule see individual properties see individual properties see individual properties per grammar see individual properties
main-rule-color <'column-rule-color'> curerentcolor Same as column-rule-color and row-rule-color no n/a by computed value type per grammar as specified
main-rule-outset <'column-rule-outset'> join Same as column-rule-outset and row-rule-outset no n/a by computed value type per grammar as specified
main-rule-style <'column-rule-style'> none Same as column-rule-style and row-rule-style no n/a discrete per grammar as specified
main-rule-width <'column-rule-width'> medium Same as column-rule-width and row-rule-width no n/a by computed value type per grammar as specified
row-rule [ <gap-rule-list> | <auto-gap-rule-list> ]# see individual properties see individual properties see individual properties see individual properties see individual properties per grammar see individual properties
row-rule-color [ <line-color-list> | <auto-line-color-list> ]# curerentcolor grid containers, flex containers, multicol containers, and masonry containers no n/a by computed value type per grammar as specified
row-rule-outset [ <length-percentage> | join ]# join grid containers, flex containers, multicol containers, and masonry containers no refer to the gap width in the perpendicular direction by computed value type per grammar as specified
row-rule-style [ <line-style-list> | <auto-line-style-list> ]# none grid containers, flex containers, multicol containers, and masonry containers no n/a discrete per grammar as specified
row-rule-width [ <line-width-list> | <auto-line-width-list> ]# medium grid containers, flex containers, multicol containers, and masonry containers no n/a by computed value type per grammar absolute length, snapped as a border width; 0 if the rule style is none or hidden