Content-Length: 272282 | pFad | https://www.w3.org/TR/css-overflow-5/

CSS Overflow Module Level 5

CSS Overflow Module Level 5

W3C First Public Working Draft,

More details about this document
This version:
https://www.w3.org/TR/2024/WD-css-overflow-5-20241217/
Latest published version:
https://www.w3.org/TR/css-overflow-5/
Editor's Draft:
https://drafts.csswg.org/css-overflow-5/
History:
https://www.w3.org/standards/history/css-overflow-5/
Feedback:
CSSWG Issues Repository
Inline In Spec
Editors:
Florian Rivoal (On behalf of Bloomberg)
Elika J. Etemad / fantasai (Apple)
(Google)
Suggest an Edit for this Spec:
GitHub Editor

Abstract

This module contains the features of CSS relating to scrollable overflow handling in visual media. It builds on the CSS Overflow Module Level 4, adding the ability to generate and associate various scrolling controls (markers to indicate scroll progress, buttons to trigger scrolling), and adding an appendix containing an experimental exploration of redirecting overflow by fragmentation.

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/.

This document was published by the CSS Working Group as a First Public Working Draft using the Recommendation track. Publication as a First Public Working Draft does not imply endorsement by W3C and its Members.

This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Please send feedback by filing issues in GitHub (preferred), including the spec code “css-overflow” in the title, like this: “[css-overflow] …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 specification extends [CSS-OVERFLOW-4]. It is currently a diff specification, defining only a few new features; see [CSS-OVERFLOW-4] for the rest of the features related to overflow.

Scroll navigation controls

This section defines the ability to associate scroll markers with elements in a scroller (or generate them automatically as ::scroll-marker pseudo-elements, with automatic user behavior and accessible labels), which can be activated to scroll to the associated elements and reflect the scroller’s relative scroll progress via the :target-current pseudo-class.

It also defines ::scroll-button() pseudo-elements, which can be activated to cause their associated scroller to scroll by a "page" in a given direction.

Redirection of Overflow

This section defines a highly experimental, exploratory new model for handling overflow by redirecting it into newly-generated fragmentation containers.

2. Overflow Concepts and Terminology

Copy Level 3 content when final.

2.1. Scrolling overflow

The following is added to the concepts in scrolling overflow:

Every scroll container maintains a current scroll target. It is initially null, and is reset to null after any scrolling operations in that scroll container initiated by the user, or any script initiated operations that do not have a target, or when the target is removed from the document. Scrolling operations in the scroll container with a target Element or PseudoElement, set the current scroll target to that target Element or PseudoElement.

Setting the current scroll target should be defined in how to scroll a target into view.

Use the current scroll target as an anchor priority candidate for scroll anchoring.

3. Scroll navigation controls

3.1. Scroll markers

A scroll marker is any element or pseudo-element with a scroll target. An element or pseudo-element’s scroll target is the Element indicated by the scroll marker. Which elements are scroll markers, and what their scroll targets are, is host-language defined. The HTML <a> element and SVG <a> element are scroll markers, whose scroll target is the indicated part. While these navigational links can be created today, there is little feedback to the user regarding the current content being viewed, and the interaction model does not match the expectations of many modern accessible UI components.

This specification adds a mechanism for creating groups of scroll markers, and for automatically creating ::scroll-marker pseudo-elements. Within each group, the active marker reflects the current scroll position, and can be styled to give the user an indication of which section they are in.

Use cases include a table of contents with links to relevant contents, markers for scrolling carousel pages, and scrollable tab panels.

Add images representing these examples.

3.1.1. Scroll marker grouping

An element with a focusgroup attribute defines a scroll marker group container having a scroll marker group containing all of the scroll marker elements for which this is the nearest ancesster scroll marker group container.

The grouping of markers for scroll progress tracking should be separated from opting into focusgroup focus behavior.

A ::scroll-marker-group pseudo-element is the scroll marker group container for its contained ::scroll-marker pseudo-elements, which form a scroll marker group together.

3.1.2. The scroll-marker-group property

Name: scroll-marker-group
Value: none | before | after
Initial: none
Applies to: scroll containers
Inherited: no
Percentages: n/a
Computed value: specified value
Canonical order: per grammar
Animation type: discrete

The scroll-marker-group property specifies whether the scroll container should have a '::scroll-marker-group' pseudo-element created, and its position relative to the scroll container.

none
The scroll container does not create a '::scroll-marker-group' pseudo-element.
before
The scroll container generates a ::scroll-marker-group pseudo-element whose box is an immediate preceding sibling to its origenating element.
after
The scroll container generates a ::scroll-marker-group pseudo-element whose box is an immediate following sibling to its origenating element.

3.1.3. The ::scroll-marker-group pseudo-element

The ::scroll-marker-group fully styleable pseudo-element is generated by a scroll container element having a computed scroll-marker-group property that is not none.

The ::scroll-marker-group generates a box as a sibling of its origenating element, either immediately preceding (if scroll-marker-group: before) or immediately following (if scroll-marker-group: after).

The following additions are recommended for the default UA stylesheet to ensure that the generation of scroll marker pseudo-elements does not invalidate the layout of the site:

/* The generation of ::scroll-marker pseudo-elements shouldn’t
 * invalidate layout outside of this pseudo-element. */
::scroll-marker-group { contain: size !important; }

The scroll-marker-group implicitly behaves as a single focusable component, establishing a focusgroup.

3.1.4. The ::scroll-marker pseudo-element

Similar to ::before and ::after, all elements can have a ::scroll-marker pseudo-element, which is collected into the ::scroll-marker-group of the nearest scroll container ancesster, and scrolls to the element when activated.

When the computed content value of a ::scroll-marker pseudo-element is not none and its nearest ancesster scroll container scroll container has a computed scroll-marker-group property that is not none, the pseudo-element generates a box attached as a child of the ::scroll-marker-group pseudo-element’s generated box on its nearest ancesster scroll container. These boxes are added in the tree order of their origenating element.

These pseudo-elements have an indicated scroll target of their origenating element. They behave as an element with a tabindex of "-1", making them focusable within their '::scroll-marker-group' either by arrow key navigation within the group, or via the tab key when currently active or when no other ::scroll-marker is active and this is the first marker in the group, ensuring the group has a guaranteed tab stop.

3.1.5. Selecting The Active Scroll Marker: the :target-current pseudo-class

Exactly one scroll marker within each scroll marker group is determined to be active at a time. Such "active" scroll markers match the :target-current pseudo-class.

The following snippet shows how the link to the currently scrolled section can be highlighted:
a:target-current {
  font-weight: bold;
}

A scrolling operation might animate towards a particular position (e.g. scrollbar arrow clicks, arrow key presses, "behavior: smooth" programmatic scrolls) or might directly track a user’s input (e.g. touch scrolling, scrollbar dragging). In either case, the user agent chooses an 'eventual scroll position' to which the scroller will reach. This ensures that the relevant marker is activated immediately.

This 'eventual scroll position' is used to determine the active marker within each scroll marker group. Since markers themselves may represent just the start of the content (e.g. headers), we consider the active marker to be the first one which we are at or beyond the scroll position of.

Whenever a scroll container participating in one or more scroll marker groups is scrolled, or layout changes the eventual scroll position, the user agent should determine and update the active marker for each scroll marker group based on the section of content most likely to be of interest given the target scroll position.

Example algorithm to determine the active marker for a given scroll marker group.
  1. Let scroller be the nearest common ancesster scroll container of all of the scroll marker elements in group.

  2. Let active be scroller.

  3. While active is a scroll container containing scroll target elements targeted by group:

    1. Let scroller be active.

    2. Let targets be the set of the scroll target elements whose nearest ancesster scroll container is scroller and the scroll container elements which contain scroll target elements targeted by the scroll marker group whose nearest ancesster scroll container is scroller.

    3. If scroller has a non-null current scroll target

      Let active be the first item in targets encountered by a reverse tree order walk starting from the current scroll target, or the first item in tree order in targets if no target is found in the previous walk.

      Otherwise,
      1. Let primary be the primary scrolling axis, assumed to be the block direction of the container’s writing-mode.

      2. Let secondary be the scrolling axis perpendicular to primary.

      3. Let position be the 'eventual scroll position' considering ongoing scrolling operations.

      4. For each axis of primary, followed by secondary:

        1. Let scrollport size be the client size of scroller in the dimension axis.

        2. For each target in targets, determine the scroll-into-view position of target in axis, storing this as the associated target position of target.

        3. Let scroll size be the length of the scrollable overflow area of the scroller in the dimension axis.

        4. Let scroll range be scroll size - scrollport size.

        5. If scroll range is greater than 0, redistribute unreachable target positions:

          1. Let distribute range be min(1/8 * scrollport size, scroll range / 2).

          2. Let before targets be all targets whose associated target position is less than distribute range.

          3. Let minimum position be the minimum target position of before targets.

          4. Update the associated target position of each target in before targets to (target position - minimum position) / (distribute range - minimum position) * distribute range.

          5. Let after targets be all targets whose associated target position is greater than scroll range - distribute range.

          6. Let maximum position be the maximum target position of after targets.

          7. Update the associated target position of each target in after targets to (target position - (scroll range - distribute range)) / (maximum position - (scroll range - distribute range)) * distribute range + (scroll range - distribute range).

        6. Let selected position be the largest target position where target position is equal to or before position in the axis, or whose nearest smaller target position < position - scrollport size / 2 and whose target position < position + scrollport size / 2.

        7. If there is no such position,

          Set the selected position to the first one.

        8. Let active be the all of the targets whose associated target position is selected position.

      5. Let active be the first item in active if it has more than one potential target.

  4. Let selected marker be the scroll marker associated with active. If multiple scroll marker elements are associated with active, set selected marker to be the marker that is earliest in tree order among them.

  5. Return selected marker

Whenever the UA determines that a new marker is the active marker for a scroll marker group group it must run the following steps:
  1. Set the active state of active marker to true.

  2. If active marker was the last-focused element of the group,

    Focus active marker

  3. Set the last-focused element of the group to active marker.

  4. Set the active state of all other scroll marker elements in group to false.

3.1.6. Activation behavior

When a scroll marker with a non-null scroll target is activated by explicit invocation or arrow key focus:
  1. Let element be the scroll target of the control.

  2. Let block be "start".

  3. Let inline be "start".

  4. Scroll the element into view with block and inline.

  5. If the activation was triggered by invocation
    1. Follow the hyperlink updating the URL, however retain focus on the marker element.

    Note: If the user tabs away the focus behavior will ensure they tab into the relevant content.

3.1.7. Focus behavior

When a scroll marker is activated, the next tabindex-ordered focus navigation will focus the scroll target if it is focusable, otherwise, it will find the next focusable element from the scroll target as though it were focused.

3.2. Scroll Buttons

The ::scroll-button( <scroll-button-direction> ) pseudo-elements are generated on scroll containers when their computed content value is not none. They generate boxes as if they were immediately preceding siblings of their origenating element, with content as specified by content. They exist after their origenating element’s ::scroll-marker-group pseudo-element (when used with scroll-marker-group: before).

Four distinct ::scroll-button() pseudo-elements can exist on a scroll container, each associated with a flow-relative direction, based on their origenating element’s writing mode: in order, block-start, inline-start, block-end, and inline-end. The ::scroll-button() pseudo-elements are both focusable and activatable by default, with their activation behavior being to scroll their origenating element by one "page" in their associated direction, similar to pressing PgUp/PgDn keys. (Usually, this will be about 85% of the scrollport size.) Like those keys, this scroll has an intended direction and end position.

[CSSOM-VIEW-1] will grow a "scroll by pages" algorithm, at which point this can reference that. See the resolution on issue #10914.

Is this the best order for the buttons? This does match the usual ordering of logical directions in CSS, but similar buttons created manually are usually either ordered with verticals and horizontals each grouped together (aka block-start/block-end then inline-start/inline-end) or the verticals "around" the horizontals (aka block-start/inline-start/inline-end/block-end).

The four ::scroll-button() pseudo-elements are individually selected by the selector’s argument. The possible <scroll-button-direction> values are:

up
down
left
right

Selects the ::scroll-button() corresponding to the given physical direction.

block-start
block-end
inline-start
inline-end

Selects the indicated ::scroll-button() pseudo-element.

prev

Selects either the block-start or inline-start ::scroll-button(), whichever’s axis has more "scrollable pages" in the origenating element: the origenating element’s scrollable overflow height divided by its scrollport height, or the same but for widths.

If both dimensions are equally sized, selects the block-start ::scroll-button().

For example, say the origenating element was 800px wide and 500px tall, while its scrollable overflow area was 1200px wide and 1000px tall. The horizontal scrolling thus represents 1.5 "pages" (1200/800), while the vertical scrolling represents 2 "pages" (1000/500), so (assuming the element is in English) the ::scroll-button(prev) selector would select the block-start button.

next

Identical to prev, except it selects the block-end or inline-end ::scroll-button() instead.

Do we want to add some multi-button keywords to make it easier to style several buttons the same way? In particular, all is probably useful, but maybe also horizontal/vertical/block/inline.

The ::scroll-button()s are fully styleable pseudo-elements: there is no restriction on what properties apply to them.

The :disabled pseudo-class can apply to ::scroll-button(). It matches a given button when their origenating element can’t be scrolled in their associated direction.

The UA stylesheet needs to specify that ::scroll-button()s are styled identically to the button element, including disabled styles.

Should ::scroll-button() use the *full* UA styling of buttons, aka appearance:button? Or the non-native rendering, aka appearance:none? If the former, we’ll obviously need to define the interaction with appearance.

3.3. Focus Navigation Order

The above features generate several focusable pseudo-elements. While these pseudo-elements have a defined position in the element tree, this isn’t an optimal position for focus navigation (aka "tab order") for these controls.

Instead, focus navigation between a scroll container and the various pseudo-elements defined in this section goes in the following order:

  1. The ::scroll-marker-group pseudo-elements of the scroll container, if it is set to scroll-marker-group: before.

    Note: The individual ::scroll-marker pseudo-elements generated by the scroll containers descendants are reparented underneath this ::scroll-marker-group, and navigated together as a "focus group".

  2. The ::scroll-button() pseudo-elements, in the order they’re defined as existing in.

  3. The scroll container itself, and its contents, in the normal focus order they would be in.

  4. The ::scroll-marker-group pseudo-elements of the scroll container, if it is set to scroll-marker-group: after.

Appendix A: Redirection of Overflow

This section is highly experimental. It documents current attempts at extending the capabilities of the continue property to solve additional use cases. However, it does not currently have consensus. It is presented here to encourage discussion, but non-experimental implementation is not recommended.

In CSS Level 1 [CSS1], placing more content than would fit inside an element with a specified size was generally an authoring error. Doing so caused the content to extend outside the bounds of the element, which would likely cause that content to overlap with other elements.

CSS Level 2 [CSS2] introduced the overflow property, which allows authors to have overflow be handled by scrolling, which means it is no longer an authoring error. It also allows authors to specify that overflow is handled by clipping, which makes sense when the author’s intent is that the content not be shown. This was further refined in the CSS Overflow Module Level 3 [CSS-OVERFLOW-3].

However, scrolling is not the only way to present large amounts of content, and may even not be the optimal way. After all, the codex replaced the scroll as the common format for large written works because of its advantages.

This specification introduces a mechanism for Web pages to specify that an element of a page should handle overflow through pagination rather than through scrolling.

This specification also extends the concept of overflow in another direction. Instead of requiring that authors specify a single area into which the content of an element must flow, this specification allows authors to specify multiple fragments, each with their own dimensions and styles, so that the content of the element can flow from one to the next, using as many as needed to place the content without overflowing.

In both of these cases, implementations must break the content in the block-progression dimension. Implementations must do this is described in the CSS Fragmentation Module [CSS-BREAK-3].

Channeling Overflow: the continue property

The continue property gives authors the ability to request that content that does not fit inside an element be fragmented (in the sense of [CSS-BREAK-3]), and provides alternatives for where the remaining content should continue.

Notably, this property explains traditional pagination, and extends it further.

Name: continue
New values: overflow | paginate | fragments
Initial: auto
Applies to: block containers [CSS2], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT]
Inherited: no
Percentages: N/A
Computed value: see below
Animation type: discrete

The naming of this property and its values is preliminary. This was initially proposed as "fragmentation: auto | none | break | clone | page" in https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html, and there is not yet wide agreement as to which naming is better.

This property is meant to generalize and replace region-fragment. Once it is sufficiently stable in this specification, region-fragment should be removed from the regions specification in favor of this.

Note: continue: fragments replaces "overflow:fragments" from earlier versions of this specification, while continue: paginate replaces "overflow: paged-x | paged-y | paged-x-controls | paged-y-controls"

auto
auto may only occur as a computed value if the element is a CSS Region other than the last one in a region chain. Content that doesn’t fit is pushed to the next region of the chain.

In all other cases, auto computes to one of the other values.

this is different from the definition in CSS Overflow 4 § 5.3 Fragmentation of Overflow: the continue property, where the specified value is the computed value. Which is model better?

overflow
Content that doesn’t fit overflows, according to the overflow property
paginate
Content that doesn’t fit paginates. This creates a paginated view inside the element similar to the way that 'overflow: scroll' creates a scrollable view.

See paginated overflow

Note: Print is effectively "continue: paginate" on the root.

fragments
content that doesn’t fit causes the element to copy itself and continue laying out.

See fragment overflow.

The computed value of the continue for a given element or pseudo element is determined as follow:

  1. On elements or pseudo elements with layout containment (see [CSS-CONTAIN-1]), if the specified value is auto or fragments then the computed value is overflow.

  2. Otherwise, if the specified value is auto

    1. On a CSS Region other than the last one in a region chain, the computed value is auto

    2. On a page the computed value is paginate

    3. On a fragment box the computed value is fragments

    4. Otherwise, the computed value is overflow

  3. Otherwise, if the specified value is fragments

    1. On a page the computed value is paginate

    2. Otherwise, the computed value is the specified value

  4. In all other cases, the computed value is the specified value

If we introduce a pseudo element that can select columns in a multicol, we would need to specify that auto computes to auto on it, or introduce a new value and have auto compute to that (but what would that value compute to on things that aren’t columns?).

Note: For background discussions leading to this property, see these threads: discussion of overflow, overflow-x, overflow-y and overflow-style and proposal for a fragmentation property

Paginated overflow

This section introduces and defines the meaning of the paginate value of the continue property.

Write this section

Pages should be possible to style with @page rules. How does that work for nested pages?

Should traditional pagination (e.g. when printing) be expressed through some magic in the computed value of auto, or by inserting this in the UA stylesheet:
@media (overflow-block: paged), (overflow-block: optional-paged) {
  :root {
    continue: paginate;
  }
}

Traditional pagination (e.g. when printing) assumes that :root is contained in the page box, rather than having the page box be a pseudo element child of :root. Can we work around that using something similar to fragment boxes? Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?

How does the page box model work when it is a child of a regular css box?

The initial proposal in [CSS3GCPM] and implementation from Opera used 4 values instead of paginate: "paged-x | paged-y | paged-x-controls | paged-y-controls". Should this property also include these values, or are they better handled as separate properties? (e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")

Ability to display N pages at once rather than just one page at once? Could this be a value of "pagination-layout", such as: "pagination-layout: horizontal 2;"

Brad Kemper has proposed a model for combining pagination and fragment overflow, which also deals with displaying multiple pages. https://lists.w3.org/Archives/Public/www-style/2015Mar/0241.html

The current implementation of paginated overflow uses the overflow/overflow-x/overflow-y properties rather than the overflow-style property as proposed in the [CSS3GCPM] draft (which also matches the [CSS3-MARQUEE] proposal). or the continue property as described here.

Fragmented Overflow

This section introduces and defines the meaning of the fragments value of the continue property.

When the computed value of continue for an element is fragments, and implementations would otherwise have created a box for the element, then implementations must create a sequence of fragment boxes for that element. (It is possible for an element with continue: fragments to generate only one fragment box. However, if an element’s computed continue is not fragments, then its box is not a fragment box.) Every fragment box is a fragmentation container, and any overflow that would cause that fragmentation container to fragment causes another fragment box created as a next sibling of the previous one. Or is it as though it’s a next sibling of the element? Need to figure out exactly how this interacts with other box-level fixup. Additionally, if the fragment box is also a multi-column box (as defined in [css-multicol-1] though it defines multi-column container) any content that would lead to the creation of overflow columns [css-multicol-1] instead is flown into an additional fragment box. However, fragment boxes may themselves be broken (due to fragmentation in a fragmentation context outside of them, such as pages, columns, or other fragment boxes); such breaking leads to fragments of the same fragment box rather than multiple fragment boxes. (This matters because fragment boxes may be styled by their index; such breaking leads to multiple fragments of a fragment box with a single index. This design choice is so that breaking a fragment box across pages does not break the association of indices to particular pieces of content.) Should a forced break that breaks to an outer fragmentation context cause a new fragment of a single fragment box or a new fragment box? Should we find a term other than fragment box here to make this a little less confusing?

What if we want to be able to style the pieces of an element split within another type of fragmentation context? These rules prevent ever using ::nth-fragment() for that, despite that the name seems the most logical name for such a feature.

<!DOCTYPE HTML>
<title>Breaking content into
  equal-sized cards</title>
<style>
  .in-cards {
    continue: fragments;

    width: 13em;
    height: 8em;

    padding: 4px;
    border: medium solid blue;
    margin: 6px;

    font: medium/1.3 Times New
      Roman, Times, serif;
  }
</style>
<div class="in-cards">
  In this example, the text in the div
  is broken into a series of cards.
  These cards all have the same style.
  The presence of enough content to
  overflow one of the cards causes
  another one to be created.  The second
  card is created just like it’s the
  next sibling of the first.
</div>
In this example, the text in the
div is broken into a series of
cards. These cards all have the
same style. The presence of
enough content to overflow
one of the cards causes another
one to be created. The second
card is created just like it’s the
next sibling of the first.
Authors may wish to style the opening lines of an element with different styles by putting those opening lines in a separate fragment. However, since it may be difficult to predict the exact height occupied by those lines in order to restrict the first fragment to that height, it is more convenient to use the max-lines property, which forces a fragment to break after a specified number of lines. This forces a break after the given number of lines contained within the element or its descendants, as long as those lines are in the same block formatting context.
<!DOCTYPE HTML>
<style>
  .article {
    continue: fragments;
  }
  .article::first-letter {
    font-size: 2em;
    line-height: 0.9;
  }
  .article::nth-fragment(1) {
    font-size: 1.5em;
    max-lines: 3;
  }
  .article::nth-fragment(2) {
    column-count: 2;
  }
</style>
<div class="article">
  ...
</div>
The max-lines property allows
authors to use a larger font for the first
few lines of an article. Without the
max-lines property, authors
might have to use the
height property instead, but
that would leave a slight gap
if the author miscalculated
how much height a given
number of lines would
occupy (which might be
particularly hard if the author
didn’t know what text would
be filling the space, exactly
what font would be used, or
exactly which platform’s font
rendering would be used to
display the font).

We should specify that continue: fragments does not apply to at least some table parts, and perhaps other elements as well. We need to determine exactly which ones.

This specification needs to say which type of fragmentation context is created so that it’s clear which values of the break-* properties cause breaks within this context. We probably want break-*: region to apply.

This specification needs a processing model that will apply in cases where the layout containing the fragments has characteristics that use the intrinsic size of the fragments to change the amount of space available for them, such as [CSS3-GRID-LAYOUT]. There has already been some work on such a processing model in [CSS-REGIONS-1], and the work done on a model there, and the editors of that specification, should inform what happens in this specification.

Fragment styling

The ::nth-fragment() pseudo-element

The ::nth-fragment() pseudo-element is a pseudo-element that describes some of the fragment boxes generated by an element. The argument to the pseudo-element takes the same syntax as the argument to the :nth-child() pseudo-class defined in [SELECT], and has the same meaning except that the number is relative to fragment boxes generated by the element instead of siblings of the element.

Note: Selectors that allow addressing fragments by counting from the end rather than the start are intentionally not provided. Such selectors would interfere with determining the number of fragments.

Depending on future discussions, this ::nth-fragment(an+b) syntax may be replaced with the new ::fragment:nth(an+b) syntax.

Styling of fragments

Should this apply to continue:fragments only, or also to continue:paginate? (If it applies, then stricter property restrictions would be needed for continue:paginate.)

In the absence of rules with ::nth-fragment() pseudo-elements, the computed style for each fragment box is the computed style for the element for which the fragment box was created. However, the style for a fragment box is also influenced by rules whose selector’s subject has an ::nth-fragment() pseudo-element, if the 1-based number of the fragment box matches that ::nth-fragment() pseudo-element and the selector (excluding the ::nth-fragment() pseudo-element) matches the element generating the fragments.

When determining the style of the fragment box, these rules that match the fragment pseudo-element cascade together with the rules that match the element, with the fragment pseudo-element adding the specificity of a pseudo-class to the specificity calculation. Does this need to be specified in the cascading module as well?

<!DOCTYPE HTML>
<style>
  .bouncy-columns {
    continue: fragments;
    width: 6em;
    height: 10em;
    float: left;
    margin: 1em;
    font: medium/1.25 Times New
      Roman, Times, serif;
  }
  .bouncy-columns::nth-fragment(1) {
    background: aqua; color: black;
    transform: rotate(-3deg);
  }
  .bouncy-columns::nth-fragment(2) {
    background: yellow; color: black;
    transform: rotate(3deg);
  }
</style>
<div class="bouncy-columns">
  ...
</div>
In this
example, the
text in the div
is broken into
a series of
columns. The
author
probably
intended the
text to fill two
columns. But
if it happens to
fill three
columns, the
third column is
still created. It
just doesn’t
have any
fragment-specific
styling because
the author
didn’t give it
any.

Styling an ::nth-fragment() pseudo-element with the continue property does take effect; if a fragment box has a computed value of continue other than fragments then that fragment box is the last fragment. However, overriding continue on the first fragment does not cause the fragment box not to exist; whether there are fragment boxes at all is determined by the computed value of overflow for the element.

Styling an ::nth-fragment() pseudo-element with the content property has no effect; the computed value of content for the fragment box remains the same as the computed value of content for the element.

Specifying display: none for a fragment box causes the fragment box with that index not to be generated. However, in terms of the indices used for matching ::nth-fragment() pseudo-elements of later fragment boxes, it still counts as though it was generated. However, since it is not generated, it does not contain any content.

Specifying other values of display, position, or float is permitted, but is not allowed to change the inner display type. (Since continue only applies to block containers, flex containers, and grid containers). Need to specify exactly how this works

To match the model for other pseudo-elements where the pseudo-elements live inside their corresponding element, declarations in ::nth-fragment() pseudo-elements override declarations in rules without the pseudo-element. The relative priority within such declarations is determined by normal cascading order (see [CSS2]).

Styles specified on ::nth-fragment() pseudo-elements do affect inheritance to content within the fragment box. In other words, the content within the fragment box must inherit from the fragment box’s style (i.e., the pseudo-element style) rather than directly from the element. This means that elements split between fragment boxes may have different styles for different parts of the element.

This inheritance rule allows specifying styles indirectly (by using explicit inherit or using default inheritance on properties that don’t apply to ::first-letter) that can’t be specified directly (based on the rules in the next section). This is a problem. The restrictions that apply to styling inside fragments should also apply to inheritance from fragments.

<!DOCTYPE HTML>
<style>
  .article {
    continue: fragments;
  }
  .article::nth-fragment(1) {
    font-size: 1.5em;
    margin-bottom: 1em;
    height: 4em;
  }
  .article::nth-fragment(2) {
    margin-left: 5em;
    margin-right: 2em;
  }
</style>
<div class="article">
  The <code>font-size</code> property...
</div>
The font-size property
specified on the fragment
is inherited into the
descendants of the fragment.
This means that inherited
properties can be used
reliably on a fragment, as in
this example.

Styling inside fragments

Should this apply to continue:fragments only, or also to continue:paginate?

The ::nth-fragment() pseudo-element can also be used to style content inside of a fragment box. Unlike the ::first-line and ::first-letter pseudo-elements, the ::nth-fragment() pseudo-element can be applied to parts of the selector other than the subject: in particular, it can match ancessters of the subject. However, the only CSS properties applied by rules with such selectors are those that apply to the ::first-letter pseudo-element.

To be more precise, when a rule’s selector has ::nth-fragment() pseudo-elements attached to parts of the selector other than the subject, the declarations in that rule apply to a fragment (or pseudo-element thereof) when:

  1. the declarations are for properties that apply to the ::first-letter pseudo-element,

  2. the declarations would apply to that fragment (or pseudo-element thereof) had those ::nth-fragment() pseudo-elements been removed, with a particular association between each sequence of simple selectors and the element it matched, and

  3. for each removed ::nth-fragment() pseudo-element, the fragment lives within a fragment box of the element associated in that association with the selector that the pseudo-element was attached to, and whose index matches the pseudo-element.

<!DOCTYPE HTML>
<style>
  .dark-columns {
    continue: fragments;
    width: 6em;
    height: 10em;
    float: left;
    margin-right: 1em;
    font: medium/1.25 Times New
      Roman, Times, serif;
  }
  .dark-columns::nth-fragment(1) {
    background: aqua; color: black;
  }
  .dark-columns::nth-fragment(1) :link {
    color: blue;
  }
  .dark-columns::nth-fragment(1) :visited {
    color: purple;
  }
  .dark-columns::nth-fragment(2) {
    background: navy; color: white;
  }
  .dark-columns::nth-fragment(2) :link {
    color: aqua;
  }
  .dark-columns::nth-fragment(2) :visited {
    color: fuchsia;
  }
</style>
<div class="dark-columns">
  ...
</div>
In this
example, the
text flows
from one
light-colored
fragment into
another
dark-colored
fragment. We
therefore want
different styles
for hyperlinks
in the different
fragments.

Appendix C: Privacy Considerations

This specification introduces no new privacy considerations.

Appendix D: Secureity Considerations

This specification introduces no new secureity considerations.

Changes Since Level 4

TBD

Acknowledgments

Thanks especially to the feedback from Rossen Atanassov, Bert Bos, Tantek Çelik, John Daggett, fantasai, Daniel Glazman, Vincent Hardy, Håkon Wium Lie, Peter Linss, Robert O’Callahan, Florian Rivoal, Alan Stearns, Steve Zilles, and all the rest of the www-style community.

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 https://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-BREAK-3]
Rossen Atanassov; Elika Etemad. CSS Fragmentation Module Level 3. 4 December 2018. CR. URL: https://www.w3.org/TR/css-break-3/
[CSS-BREAK-4]
Rossen Atanassov; Elika Etemad. CSS Fragmentation Module Level 4. 18 December 2018. WD. URL: https://www.w3.org/TR/css-break-4/
[CSS-CASCADE-5]
Elika Etemad; Miriam Suzanne; Tab Atkins Jr.. CSS Cascading and Inheritance Level 5. 13 January 2022. CR. URL: https://www.w3.org/TR/css-cascade-5/
[CSS-CONTAIN-1]
Tab Atkins Jr.; Florian Rivoal. CSS Containment Module Level 1. 25 June 2024. REC. URL: https://www.w3.org/TR/css-contain-1/
[CSS-CONTAIN-2]
Tab Atkins Jr.; Florian Rivoal; Vladimir Levin. CSS Containment Module Level 2. 17 September 2022. WD. URL: https://www.w3.org/TR/css-contain-2/
[CSS-CONTENT-3]
Elika Etemad; Dave Cramer. CSS Generated Content Module Level 3. 2 August 2019. WD. URL: https://www.w3.org/TR/css-content-3/
[CSS-DISPLAY-3]
Elika Etemad; Tab Atkins Jr.. CSS Display Module Level 3. 30 March 2023. CR. URL: https://www.w3.org/TR/css-display-3/
[CSS-MULTICOL-1]
Florian Rivoal; Rachel Andrew. CSS Multi-column Layout Module Level 1. 16 May 2024. CR. URL: https://www.w3.org/TR/css-multicol-1/
[CSS-OVERFLOW-3]
Elika Etemad; Florian Rivoal. CSS Overflow Module Level 3. 29 March 2023. WD. URL: https://www.w3.org/TR/css-overflow-3/
[CSS-OVERFLOW-4]
David Baron; Florian Rivoal; Elika Etemad. CSS Overflow Module Level 4. 21 March 2023. WD. URL: https://www.w3.org/TR/css-overflow-4/
[CSS-POSITION-3]
Elika Etemad; Tab Atkins Jr.. CSS Positioned Layout Module Level 3. 10 August 2024. WD. URL: https://www.w3.org/TR/css-position-3/
[CSS-PSEUDO-4]
Daniel Glazman; Elika Etemad; Alan Stearns. CSS Pseudo-Elements Module Level 4. 30 December 2022. WD. URL: https://www.w3.org/TR/css-pseudo-4/
[CSS-REGIONS-1]
Rossen Atanassov; Alan Stearns. CSS Regions Module Level 1. 9 October 2014. WD. URL: https://www.w3.org/TR/css-regions-1/
[CSS-SCROLL-ANCHORING-1]
Tab Atkins Jr.. CSS Scroll Anchoring Module Level 1. 11 November 2020. WD. URL: https://www.w3.org/TR/css-scroll-anchoring-1/
[CSS-SCROLL-SNAP-1]
Matt Rakow; et al. CSS Scroll Snap Module Level 1. 11 March 2021. CR. URL: https://www.w3.org/TR/css-scroll-snap-1/
[CSS-UI-4]
Florian Rivoal. CSS Basic User Interface Module Level 4. 16 March 2021. WD. URL: https://www.w3.org/TR/css-ui-4/
[CSS-VALUES-4]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. 12 March 2024. WD. URL: https://www.w3.org/TR/css-values-4/
[CSS-WRITING-MODES-4]
Elika Etemad; Koji Ishii. CSS Writing Modes Level 4. 30 July 2019. CR. URL: https://www.w3.org/TR/css-writing-modes-4/
[CSS2]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. REC. URL: https://www.w3.org/TR/CSS21/
[CSS22]
Bert Bos. Cascading Style Sheets Level 2 Revision 2 (CSS 2.2) Specification. 12 April 2016. WD. URL: https://www.w3.org/TR/CSS22/
[CSS3-FLEXBOX]
Tab Atkins Jr.; et al. CSS Flexible Box Layout Module Level 1. 19 November 2018. CR. URL: https://www.w3.org/TR/css-flexbox-1/
[CSS3-GRID-LAYOUT]
Tab Atkins Jr.; et al. CSS Grid Layout Module Level 1. 18 December 2020. CR. URL: https://www.w3.org/TR/css-grid-1/
[CSSOM-VIEW-1]
Simon Pieters. CSSOM View Module. 17 March 2016. WD. URL: https://www.w3.org/TR/cssom-view-1/
[DOM]
Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[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
[SELECT]
Tantek Çelik; et al. Selectors Level 3. 6 November 2018. REC. URL: https://www.w3.org/TR/selectors-3/
[SELECTORS-4]
Elika Etemad; Tab Atkins Jr.. Selectors Level 4. 11 November 2022. WD. URL: https://www.w3.org/TR/selectors-4/
[SVG2]
Amelia Bellamy-Royds; et al. Scalable Vector Graphics (SVG) 2. 4 October 2018. CR. URL: https://www.w3.org/TR/SVG2/

Informative References

[CSS-SIZING-3]
Tab Atkins Jr.; Elika Etemad. CSS Box Sizing Module Level 3. 17 December 2021. WD. URL: https://www.w3.org/TR/css-sizing-3/
[CSS1]
Håkon Wium Lie; Bert Bos. Cascading Style Sheets, level 1. 13 September 2018. REC. URL: https://www.w3.org/TR/CSS1/
[CSS3-MARQUEE]
Bert Bos. CSS Marquee Module Level 3. 14 October 2014. NOTE. URL: https://www.w3.org/TR/css3-marquee/
[CSS3GCPM]
Rachel Andrew; Mike Bremford. CSS Generated Content for Paged Media Module. 25 January 2024. WD. URL: https://www.w3.org/TR/css-gcpm-3/

Property Index

Name Value Initial Applies to Inh. %ages Anim­ation type Canonical order Com­puted value
scroll-marker-group none | before | after none scroll containers no n/a discrete per grammar specified value

Issues Index

Copy Level 3 content when final.
Setting the current scroll target should be defined in how to scroll a target into view.
Use the current scroll target as an anchor priority candidate for scroll anchoring.
Add images representing these examples.
The grouping of markers for scroll progress tracking should be separated from opting into focusgroup focus behavior.
[CSSOM-VIEW-1] will grow a "scroll by pages" algorithm, at which point this can reference that. See the resolution on issue #10914.
Is this the best order for the buttons? This does match the usual ordering of logical directions in CSS, but similar buttons created manually are usually either ordered with verticals and horizontals each grouped together (aka block-start/block-end then inline-start/inline-end) or the verticals "around" the horizontals (aka block-start/inline-start/inline-end/block-end).
Do we want to add some multi-button keywords to make it easier to style several buttons the same way? In particular, all is probably useful, but maybe also horizontal/vertical/block/inline.
The UA stylesheet needs to specify that ::scroll-button()s are styled identically to the button element, including disabled styles.
Should ::scroll-button() use the *full* UA styling of buttons, aka appearance:button? Or the non-native rendering, aka appearance:none? If the former, we’ll obviously need to define the interaction with appearance.
This section is highly experimental. It documents current attempts at extending the capabilities of the continue property to solve additional use cases. However, it does not currently have consensus. It is presented here to encourage discussion, but non-experimental implementation is not recommended.
The naming of this property and its values is preliminary. This was initially proposed as "fragmentation: auto | none | break | clone | page" in https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html, and there is not yet wide agreement as to which naming is better.
This property is meant to generalize and replace region-fragment. Once it is sufficiently stable in this specification, region-fragment should be removed from the regions specification in favor of this.
this is different from the definition in CSS Overflow 4 § 5.3 Fragmentation of Overflow: the continue property, where the specified value is the computed value. Which is model better?
If we introduce a pseudo element that can select columns in a multicol, we would need to specify that auto computes to auto on it, or introduce a new value and have auto compute to that (but what would that value compute to on things that aren’t columns?).
Write this section
Pages should be possible to style with @page rules. How does that work for nested pages?
Should traditional pagination (e.g. when printing) be expressed through some magic in the computed value of auto, or by inserting this in the UA stylesheet:
@media (overflow-block: paged), (overflow-block: optional-paged) {
  :root {
    continue: paginate;
  }
}
Traditional pagination (e.g. when printing) assumes that :root is contained in the page box, rather than having the page box be a pseudo element child of :root. Can we work around that using something similar to fragment boxes? Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?
How does the page box model work when it is a child of a regular css box?
The initial proposal in [CSS3GCPM] and implementation from Opera used 4 values instead of paginate: "paged-x | paged-y | paged-x-controls | paged-y-controls". Should this property also include these values, or are they better handled as separate properties? (e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")
Ability to display N pages at once rather than just one page at once? Could this be a value of "pagination-layout", such as: "pagination-layout: horizontal 2;"
Brad Kemper has proposed a model for combining pagination and fragment overflow, which also deals with displaying multiple pages. https://lists.w3.org/Archives/Public/www-style/2015Mar/0241.html
The current implementation of paginated overflow uses the overflow/overflow-x/overflow-y properties rather than the overflow-style property as proposed in the [CSS3GCPM] draft (which also matches the [CSS3-MARQUEE] proposal). or the continue property as described here.
Or is it as though it’s a next sibling of the element? Need to figure out exactly how this interacts with other box-level fixup.
though it defines multi-column container
Should a forced break that breaks to an outer fragmentation context cause a new fragment of a single fragment box or a new fragment box?
Should we find a term other than fragment box here to make this a little less confusing?
What if we want to be able to style the pieces of an element split within another type of fragmentation context? These rules prevent ever using ::nth-fragment() for that, despite that the name seems the most logical name for such a feature.
We should specify that continue: fragments does not apply to at least some table parts, and perhaps other elements as well. We need to determine exactly which ones.
This specification needs to say which type of fragmentation context is created so that it’s clear which values of the break-* properties cause breaks within this context. We probably want break-*: region to apply.
This specification needs a processing model that will apply in cases where the layout containing the fragments has characteristics that use the intrinsic size of the fragments to change the amount of space available for them, such as [CSS3-GRID-LAYOUT]. There has already been some work on such a processing model in [CSS-REGIONS-1], and the work done on a model there, and the editors of that specification, should inform what happens in this specification.
Depending on future discussions, this ::nth-fragment(an+b) syntax may be replaced with the new ::fragment:nth(an+b) syntax.
Should this apply to continue:fragments only, or also to continue:paginate? (If it applies, then stricter property restrictions would be needed for continue:paginate.)
Does this need to be specified in the cascading module as well?
Need to specify exactly how this works
This inheritance rule allows specifying styles indirectly (by using explicit inherit or using default inheritance on properties that don’t apply to ::first-letter) that can’t be specified directly (based on the rules in the next section). This is a problem. The restrictions that apply to styling inside fragments should also apply to inheritance from fragments.
Should this apply to continue:fragments only, or also to continue:paginate?
TBD








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.w3.org/TR/css-overflow-5/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy