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 DefinitionsThis 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. Gap decorationsVarious layouts in CSS such as multicol containers, flex containers, grid containers, and masonry containers position child boxes adjacent to each other with gaps, also known as gutters, between them. Each such gap may contain a gap decoration, which is a visible separator (such as a line) painted between adjacent boxes.
.grid-with-spans { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; }A grid with spanning items and gap decorations.
.flex { display: flex; flex-wrap: wrap; gap: 20px; width: 500px; row-rule: 6px solid red; column-rule: 6px solid blue; }A flexbox with gap decorations. 2.1. Layout and painting
This specification does not generally define the geometry of gaps in container layouts; that is left to other specifications. See CSS Box Alignment 3 § 8 Gaps Between Boxes for definitions pertaining to multicol containers, flex containers, and grid containers.
Gap decorations do not take up space. That is, the presence or width of a gap decoration will not alter the placement of anything else. If a gap decoration is wider than its gap, any adjacent boxes will overlap the decoration, and in some cases the decoration may extend outside the box of the container. Gap decorations are painted just above the border of the container. For scrollable containers, note that while the border and background of the container aren’t scrolled, the decorations need to scroll along with items in the container.
A gap intersection point is defined to exist in each of the following locations:
The following examples illustrate the locations of gap intersection points, marked with a magenta + in each case.
.grid { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; background: rgb(255 255 128); } .grid > * { border: 1px dashed black; }Locations of gap intersection points in a grid with spanning items. Note the presence of gap intersection points even where a spanning item touches the edge of a container, and where an intersection is flanked by spanning items on either side (for example between #2 and #6, or #4 and #7).
.flex { display: flex; flex-wrap: wrap; gap: 20px; width: 500px; background: rgb(255 255 128); } .flex > * { border: 1px dashed black; }Locations of gap intersection points in a flexbox. Note the presence of gap intersection points at edges of the container, and the presence of two gap intersection points in close proximity where items in adjacent rows don’t quite line up with each other (between #2, #3, #4, and, #5).
Note: CSS Box Alignment 3 § 8.1 Row and Column Gutters: the row-gap and column-gap properties defines cross-direction gaps in flex containers as being between adacent flex items in a single line. Thus, in the example above, even though the right edges of #4 and #7 line up, and the left edges of #5 and #8 line up, the spaces between those two pairs of items are two distinct gaps since they are on different lines. Therefore, the intersection between #4, #5, #7, and #8 contains two gap intersection points whose locations coincide: one at the bottom of the gap between #4 and #5, and one at the top of the gap between #7 and #8.
Gap decorations are painted relative to pairs of gap intersection points, in the center of the corresponding gap and parallel to its edges.
2.2. Breaking gap decorations into segments: The column-rule-break, row-rule-break, and rule-break propertiesSets the behavior for breaking decorations within a given gap into segments at visible "T" or "cross" intersections formed by items in the container. Precise details for how to apply these values are given in the steps to determine pairs of gap decoration endpoints.
Sets the column-rule-break and row-rule-break properties to the same value.
2.2.1. Pairing gap intersection points into segmentsIn the context of a given
gap, a pair of
gap intersection points aand
bis considered
discontiguousif a line segment from
ato
b, with the same width as
gap, intersects a child item in the container.
Note: The primary use case for this definition is to avoid having gap decorations intersect spanning items when not intended by the author, for example when a spanning item touches the edge of the container, or when a spanning item forms a "T intersection". However, the specific phrasing of the definition is also intended to address cases such as the one below:
The four marked gap intersection points fall along a common gap centerline. However, because item 3 is slightly wider than items 1 and 5, the second and third points from the top are discontiguous. Thus, the two upper gap intersection points form a pair, and the two lower gap intersection points form a pair. (There is an additional pair of gap intersection points, slightly offset to the right of the two middle points, which are not marked. These points will form another pair.)
To
determine pairs of gap decoration endpointswithin a given
gap:
A gap decoration is painted between each pair of endpoints identified using the steps above.
The following examples illustrate various settings for the *-rule-break properties. To make the differences more apparent, the *-rule-outset properties are set to 0.
.break-none-grid { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; rule-break: none; rule-outset: 0px; }Grid gap decorations with no breaks. Note that the gap decorations extend "behind" items placed in the grid.
.break-spanning-item-grid { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; rule-break: spanning-item; rule-outset: 0px; }Grid gap decorations broken at gap intersection points that are not adjacent to spanning items.
.break-intersection-grid { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; rule-break: intersection; rule-outset: 0px; }Grid gap decorations broken at every gap intersection point that is not flanked by spanning items on opposing sides.
.break-none-flex { display: flex; flex-wrap: wrap; gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; rule-break: none; rule-outset: 0px; }Flexbox gap decorations with no breaks. Note that each flex line has its own distinct gaps. Therefore, gap decorations in adjacent flex lines are separate from each other even if the gaps happen to line up.
Note: Because flexbox has no concept of spanning items, spanning-item on a flexbox has the same effect as none.
.break-intersection-flex { display: flex; flex-wrap: wrap; gap: 20px; width: 500px; gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; rule-break: intersection; rule-outset: 0px; }Flexbox gap decorations broken at every gap intersection point. 2.3. Adjusting gap decoration endpoints: The column-rule-outset, row-rule-outset, and rule-outset properties
These properties can be used to offset the endpoints of gap decorations relative to the gap intersection points which would normally determine their endpoints. The initial value of 50% places the gap decoration endpoint in the center of the intersection. With a value of 0, the gap decoration endpoint will coincide with the edge of the intersection. Positive values extend towards the center of the intersection; negative values recede from it. These offsets also apply at the edges of the container, where positive values may extend beyond the content bounds of the container.
Sets the column-rule-outset and row-rule-outset properties to the same value.
.outset-0px { column-rule-outset: 0px; column-rule-break: intersection; }An outset of 0px aligns the ends of gap decorations with adjacent items.
.outset-5px { column-rule-outset: 5px; column-rule-break: intersection; }An outset of 5px extends the ends of gap decorations slightly beyond the edges of adjacent items.
.outset-50percent { column-rule-outset: 50%; column-rule-break: intersection; }An outset of 50% - the initial value - extends each end of a gap decoration halfway into its intersection. Neighboring gap decorations "meet in the middle" to create a continuous line. Note that at the edges of the container, the crossing gap width is defined to be 0, so the outset value of 50% resolves to 0 and thus the gap decoration does not extend beyond the bounds of the container. (Contrast with the previous example, which specified an outset in px units.)
.outset-negative-5px { column-rule-outset: -5px; column-rule-break: intersection; }An outset of -5px shortens the ends of gap decorations relative to the edges of adjacent items.
When considering the gap intersection points within a given gap, each point is assigned a crossing gap width, defined as follows:
To
compute the offsetfor a given
gap intersection point pointwithin a given
gap:
For details on how the offset is applied, see the steps to determine pairs of gap decoration endpoints.
2.4. Gap decoration paint order: The rule-paint-order propertySets the paint order for gap decorations in two-dimensional containers.
The following examples illustrate adjustment of gap decoration paint order using the rule-paint-order property.
.row-over-coulumn { rule-paint-order: row-over-column; row-rule: 6px solid red; column-rule: 6px solid blue; }Row-over-column gap decoration paint order.
rule-paint-order: column-over-row; row-rule: 6px solid red; column-rule: 6px solid blue;Column-over-row gap decoration paint order. 3. Color, style, and width
Property definitions in this section supersede the definitions of properties with the same names in [CSS-MULTICOL-1].
3.1. Gap decoration color: The column-rule-color and row-rule-color properties<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> ]+ )
<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> ]+ )
These properties set the styles of gap decorations. The <line-style> values are interpreted as in the collapsing border model.
3.3. Gap decoration width: The column-rule-width and row-rule-width properties<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> ]+ )
This property sets the widths of gap decorations. Negative values are not allowed.
If the computed value of column-rule-style is none or hidden, then the computed value of column-rule-width is 0. This behavior is for backwards compatibility with CSS Multicol 1 § 4.4 The Width Of Column Rules: the column-rule-width property.
Should the "force to 0" behavior apply when lists of values are involved? If so, how should this be handled with unaligned lists?
3.4. Lists of values and the repeat() notationEach of the properties in this section accepts a space-separated list of values. Setting multiple values in this way allows for varying gap decorations within a given container.
An author might specify alternating red and blue column rules as follows:
column-rule-width: 1px; column-rule-style: solid; column-rule-color: red blue;
Such a list may contain repeat() notations. Similar to CSS Grid Layout 1 § 7.2.3 Repeating Rows and Columns: the repeat() notation, these notations allow a series of gap decorations that exhibit a recurring pattern to be written in a more compact form.
The generic form of the repeat() syntax is, approximately,
repeat( [ <integer [1,∞]> | auto ] , <value>+ )
The first argument to repeat() specifies the number of repetitions.
An author may write:
column-rule-color: gray red blue red blue red blue gray;
Or shorten to the following, which produces the same sequence of colors:
column-rule-color: gray repeat(3, red blue) gray;
Continuing from the previous example, if the author does not know how many columns will be in the final layout, they might instead write:
column-rule-color: gray repeat(auto, red blue) gray;
Which will produce a gray decoration in the first and last column gaps, and alternating red and blue decorations in the in-between column gaps.
The second argument to repeat() is a space-separated list of values that would be accepted by the property in which the repeat() appears.
To
assign gap decoration valuesto a list of
gapsusing a list of
values:
To
assign gap decoration values in reverseto a list of
gapsusing a list of
values, follow the same steps as to
assign gap decoration values, except that in step 2, change all instances of "first" to "last".
3.5. Gap decoration shorthands: The column-rule and row-rule properties<gap-rule-list> = <gap-rule-or-repeat># <gap-auto-rule-list> = <gap-rule-or-repeat>#? , <gap-auto-repeat-rule> , <gap-rule-or-repeat>#? <gap-rule-or-repeat> = <gap-rule> | <gap-repeat-rule> <gap-repeat-rule> = repeat( <integer [1,∞]> , <gap-rule># ) <gap-auto-repeat-rule> = repeat( auto , <gap-rule># ) <gap-rule> = <line-width> || <line-style> || <color>
These shorthands set the corresponding width, style, and color properties as a set.
3.6. Bi-directional gap decoration shorthands: The rule-color, rule-style, rule-width, and rule propertiesThese shorthands set the corresponding column and row properties to the same values.
Privacy ConsiderationsNo new privacy considerations have been reported on this specification.
Security ConsiderationsNo new security considerations have been reported on this specification.
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:
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.
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.
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.
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4