# CSS Overscroll Behavior Module Level 1

## Editor’s Draft, 1 January 1970

Specification Metadata

This version:
  https://drafts.csswg.org/css-overscroll-1/
Latest published version:
  https://www.w3.org/TR/css-overscroll-1/
Editors:
  Benoit Girard (Facebook)
  Majid Valipour (Google)
Issue Tracking:
  GitHub Issues
Suggest an Edit for this Spec:
  GitHub Editor

Copyright © 1970 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and permissive document license rules apply.

## Abstract

This module defines overscroll-behavior to control the behavior when the scroll position of a scroll container reaches the edge of the scrollport. This allows content authors to hint that the boundary default actions, such as scroll chaining and overscroll, should not be triggered.

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 is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress.

GitHub Issues are preferred for discussion of this specification. When filing an issue, please put the text “css-overscroll” in the title, preferably like this: “[css-overscroll] …summary of comment…”. All issues and comments are archived, and there is also a historical archive.

This document was produced by the CSS Working Group.

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.

This document is governed by the 1 March 2019 W3C Process Document.

## 1. Introduction

This section is not normative.

A content author does not necessarily want scroll chaining to occur for all scroll containers. Some scroll containers may be part of a containing block chain but may serve a different logical purpose in the document and may want to prevent scrolling from continuing up the scroll chain. To achieve this, a content author will install event listeners without the passive flag set and will use preventDefault when there is a risk that scroll chaining will occur. This is detrimental for the following reasons:

- The user agent may in the future introduce new input methods for scrolling that are not supported by the content author’s event listeners.

- A non passive event listener will delay scrolling because the user agent will have to wait for the result of the event listener to determine if preventDefault was called causing increased scroll latency.

- When scrolling is performed near the edge of the scroll boundary, the default action may cause both scrolling to the edge of the scroll container and a boundary default action. Calling preventDefault will not only cancel the boundary default action but also the scroll to the edge of the scrollport.

- The default action for the event may also provide additional behavior that the author does not want to cancel such as an overscroll affordance. preventDefault doesn’t allow the content author to cancel only some of the default actions such as scroll chaining.

Thus, it is not possible for a content author to control scroll chaining and overscroll in a robust, performant and forward compatible way. The overscroll-behavior property fixes this shortcoming.

## 2. Motivating Examples

A position fixed left navigation bar does not want to hand off scrolling to the document because a scroll gesture performed on the navigation bar is almost never meant to scroll the document. Note that using the native overscroll affordances are still desirable while scroll chaining is to be prevented.

    #sidebar {
      overscroll-behavior: contain;
    }

In this case, the author can use contain on the sidebar to prevent scrolling from being chained to the parent document element.

A page wants to implement their own pull-to-refresh effect and thus needs to disable browser native overscroll action.

    html {
      /* only disable pull-to-refresh but allow swipe navigations */
      overscroll-behavior-y: contain;
    }

In this case, the author can use contain on the viewport defining element to prevent overscroll from triggering navigation actions.

A infinite scrollers loads more content as user reaches the boundary and thus wants to disable the potentially confusing rubber banding effect in addition to scroll chaining.

    #infinite_scroller {
      overscroll-behavior-y: none;
    }

In this case the the author can use none on the infinite scroller to prevent both scroll chaining and overscroll affordance.

## 3. Scroll chaining and boundary default actions

Operating Systems have rules for scrolling such as scroll chaining and overscroll affordances. This specification does not mandate if and how scroll chaining or overscroll affordances be implemented. This specification only allows the content author to disable them if any are implemented.

Scroll chaining is when scrolling is propagated from one scroll container to an ancestor scroll container following the scroll chain. Typically scroll chaining is performed starting at the event target recursing up the containing block chain. When a scroll container in this chain receives a scroll event or gesture it may act on it and/or pass it up the chain. Chaining typically occurs when the scrollport has reached its boundary.

A scroll chain is the order in which scrolling is propagated from one scroll container to another. The viewport participates in scroll chaining as the document’s scrollingElement, both regarding placement in the scroll chain as well as adhering to the chaining rules applied to it.

Scroll boundary refers to when the scroll position of a scroll container reaches the edge of the scrollport. If a scroll container has no potential to scroll, because it does not overflow in the direction of the scroll, the element is always considered to be at the scroll boundary.

Boundary default action refers to the user-agent-defined default action performed when scrolling against the edge of the scrollport. A local boundary default action is a boundary default action which is performed on the scroll container without interacting with the page, for example displaying a overscroll UI affordance. Conversely, a non-local boundary default action interacts with the page, for example scroll chaining or a navigation action.

## 4. Overscroll Behavior Properties

The overscroll behavior controls the permitted boundary default action for a scroll container element when its scrollport reaches the boundary of its scroll box.

The overscroll-behavior property specifies the overscroll behavior for a scroll container element. It allows the content author to specify that a scroll container element must prevent scroll chaining and/or overscroll affordances.

An element that is not scroll container must accept but ignore the values of this property. This property must be applied to all scrolling methods supported by the user agent.

Note: This property should provide guarantees that are, at least, as strong as preventDefault for preventing both scroll chaining and overscroll. Doing otherwise would cause content authors to use preventDefault instead.

Name: | overscroll-behavior
Value: | [ contain | none | auto ]{1,2}
Initial: | auto auto
Applies to: | scroll container elements
Inherited: | no
Percentages: | n/a
Computed value: | see individual properties
Canonical order: | per grammar
Animation type: | discrete
Media: | visual

The overscroll-behavior property is a shorthand property that sets the specified values of overscroll-behavior-x and overscroll-behavior-y in that order. If only one value is specified, the second value defaults to the same value.

Values have the following meanings:

contain
  This value indicates that the element must not perform non-local boundary default actions such as scroll chaining or navigation. The user agent must not perform scroll chaining to any ancestors along the scroll chain regardless of whether the scroll originated at this element or one of its descendants. This value must not modify the behavior of how local boundary default actions should behave, such as showing any overscroll affordances.
none
  This value implies the same behavior as contain and in addition this element must also not perform local boundary default actions such as showing any overscroll affordances.
auto
  This value indicates that the user agent should perform the usual boundary default action with respect to scroll chaining, overscroll and navigation gestures.

Note: In the case where a user agent does not implement scroll chaining and overscroll affordances, these values will have no side effects for a compliant implementation.

Note: Programmatic scrolling is clamped and can not trigger any boundary default actions.

### 4.1. Physical Longhands for overscroll-behavior

Name: | overscroll-behavior-x, overscroll-behavior-y
Value: | contain | none | auto
Initial: | auto
Applies to: | scroll container elements
Inherited: | no
Percentages: | N/A
Computed value: | as specified
Canonical order: | per grammar
Animation type: | discrete
Media: | visual

The overscroll-behavior-x property specifies the overscroll behavior in the horizontal axis and the overscroll-behavior-y property specifies the overscroll behavior in the vertical axis. When scrolling is performed along both the horizontal and vertical axes at the same time, the overscroll behavior of each respective axis should be considered independently.

### 4.2. Flow-relative Longhands for overscroll-behavior

Name: | overscroll-behavior-inline, overscroll-behavior-block
Value: | contain | none | auto
Initial: | auto
Applies to: | scroll container elements
Inherited: | no
Percentages: | N/A
Computed value: | as specified
Canonical order: | per grammar
Animation type: | discrete
Media: | visual

These properties correspond to the overscroll-behavior-x and overscroll-behavior-y properties. The mapping depends on the element’s writing-mode.

## 5. Security and Privacy Considerations

There are no known security or privacy impacts of this feature. The feature may be used to prevent certain native UI features such as overscroll affordances and overscroll navigations (e.g., pull- to-refresh, swipe navigations). However, this does not expose any additional abilities beyond what is already possible in the platform e.g., by preventing the default action of the event that would cause a scroll.

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

### Requirements for Responsible Implementation of CSS

The following sections define several conformance requirements for implementing CSS responsibly, in a way that promotes interoperability in the present and future.

#### 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 property 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.

#### Implementations of CR-level Features

Once a specification reaches the Candidate Recommendation stage, implementers should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec, and should avoid exposing a prefixed variant of that feature.

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

- auto, in §4
- Boundary default action, in §3
- contain, in §4
- local boundary default action, in §3
- none, in §4
- non-local boundary default action, in §3
- overscroll behavior, in §4
- overscroll-behavior, in §4
- overscroll-behavior-block, in §4.2
- overscroll-behavior-inline, in §4.2
- overscroll-behavior-x, in §4.1
- overscroll-behavior-y, in §4.1
- Scroll boundary, in §3
- scroll chain, in §3
- Scroll chaining, in §3

https://drafts.csswg.org/css-overflow-3/#overflow Referenced in:

- 3. Scroll chaining and boundary default actions

https://drafts.csswg.org/css-overflow-3/#scrollport Referenced in:

- Unnumbered Section
- 1. Introduction
- 3. Scroll chaining and boundary default actions (2) (3)
- 4. Overscroll Behavior Properties

https://drafts.csswg.org/css-values-4/#mult-num-range Referenced in:

- 4. Overscroll Behavior Properties

https://drafts.csswg.org/css-values-4/#comb-one Referenced in:

- 4. Overscroll Behavior Properties (2)
- 4.1. Physical Longhands for overscroll-behavior (2)
- 4.2. Flow-relative Longhands for overscroll-behavior (2)

https://drafts.csswg.org/css-writing-modes-4/#propdef-writing-mode Referenced in:

- 4.2. Flow-relative Longhands for overscroll-behavior

### Terms defined by reference

- [css-overflow-3] defines the following terms:
  - overflow
  - scrollport
- [css-values-4] defines the following terms:
  - {a,b}
  - |
- [css-writing-modes-4] defines the following terms:
  - writing-mode

## References

### Normative References

[CSS-OVERFLOW-3]
  David Baron; Elika Etemad; Florian Rivoal. CSS Overflow Module Level 3. 31 July 2018. WD. URL: https://www.w3.org/TR/css-overflow-3/
[CSS-VALUES-4]
  Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. 31 January 2019. WD. URL: https://www.w3.org/TR/css-values-4/
[CSS-WRITING-MODES-4]
  Elika Etemad; Koji Ishii. CSS Writing Modes Level 4. 24 May 2018. CR. URL: https://www.w3.org/TR/css-writing-modes-4/
[RFC2119]
  S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119

## Property Index

Name | Value | Initial | Applies to | Inh. | %ages | Animation type | Canonical order | Computed value | Media
--- | --- | --- | --- | --- | --- | --- | --- | --- | ---
overscroll-behavior | [ contain | none | auto ]{1,2} | auto auto | scroll container elements | no | n/a | discrete | per grammar | see individual properties | visual
overscroll-behavior-block | contain | none | auto | auto | scroll container elements | no | N/A | discrete | per grammar | as specified | visual
overscroll-behavior-inline | contain | none | auto | auto | scroll container elements | no | N/A | discrete | per grammar | as specified | visual
overscroll-behavior-x | contain | none | auto | auto | scroll container elements | no | N/A | discrete | per grammar | as specified | visual
overscroll-behavior-y | contain | none | auto | auto | scroll container elements | no | N/A | discrete | per grammar | as specified | visual

#scroll-chaining Referenced in:

- 1. Introduction (2)
- 3. Scroll chaining and boundary default actions
- 4. Overscroll Behavior Properties

#scroll-chain Referenced in:

- 1. Introduction
- 3. Scroll chaining and boundary default actions
- 4. Overscroll Behavior Properties

#scroll-boundary Referenced in:

- 1. Introduction

#boundary-default-action Referenced in:

- 1. Introduction (2)
- 3. Scroll chaining and boundary default actions
- 4. Overscroll Behavior Properties (2) (3)

#local-boundary-default-action Referenced in:

- 4. Overscroll Behavior Properties (2)

#non-local-boundary-default-action Referenced in:

- 4. Overscroll Behavior Properties

#overscroll-behavior Referenced in:

- 4. Overscroll Behavior Properties
- 4.1. Physical Longhands for overscroll-behavior (2) (3)

#propdef-overscroll-behavior Referenced in:

- 1. Introduction
- 4. Overscroll Behavior Properties (2)
- 4.1. Physical Longhands for overscroll-behavior
- 4.2. Flow-relative Longhands for overscroll-behavior

#valdef-overscroll-behavior-contain Referenced in:

- 2. Motivating Examples (2)
- 4. Overscroll Behavior Properties

#valdef-overscroll-behavior-none Referenced in:

- 2. Motivating Examples

#propdef-overscroll-behavior-x Referenced in:

- 4. Overscroll Behavior Properties
- 4.1. Physical Longhands for overscroll-behavior
- 4.2. Flow-relative Longhands for overscroll-behavior

#propdef-overscroll-behavior-y Referenced in:

- 4. Overscroll Behavior Properties
- 4.1. Physical Longhands for overscroll-behavior
- 4.2. Flow-relative Longhands for overscroll-behavior