CSS Scroll Snap Module Level 1

CSS Scroll Snap Module Level 1

W3C Candidate Recommendation,

This version:
https://www.w3.org/TR/2016/CR-css-scroll-snap-1-20161020/
Latest published version:
https://www.w3.org/TR/css-scroll-snap-1/
Editor's Draft:
https://drafts.csswg.org/css-scroll-snap-1/
Previous Versions:
https://www.w3.org/TR/2016/WD-css-scroll-snap-1-20160623/
https://www.w3.org/TR/2016/WD-css-snappoints-1-20160329/
https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/
Feedback:
www-style@w3.org with subject line “[css-scroll-snap] … message topic …” (archives)
Editors:
Matt Rakow (Microsoft)
Jacob Rossi (Microsoft)
Tab Atkins-Bittner (Google)
Elika J. Etemad / fantasai (Invited Expert)

Abstract

This module contains features to control panning and scrolling behavior with “snap positions”.

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

Status of this document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. 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 produced by the CSS Working Group (part of the Style Activity) as a Candidate Recommendation. This document is intended to become a W3C Recommendation. This document will remain a Candidate Recommendation at least until in order to ensure the opportunity for wide review.

The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-scroll-snap” in the subject, preferably like this: “[css-scroll-snap] …summary of comment…

Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. 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.

There is no test suite, and no preliminary implementation report at this time.

This document was produced by a group operating under the 5 February 2004 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 September 2015 W3C Process Document.

For changes since the last draft, see the Changes section.

The following features are at-risk, and may be dropped during the CR period:

“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.

1. Introduction

This section is not normative.

Popular UX paradigms for scrollable content frequently employ paging through content, or sectioning into logical divisions. This is especially true for touch interactions where it is quicker and easier for users to quickly pan through a flatly-arranged breadth of content rather than delving into a heirarchical structure through tap navigation. For example, it is easier for a user to view many photos in a photo album by panning through a photo slideshow view rather than tapping on individual photos in an album.

However, given the imprecise nature of scrolling inputs like touch panning and mousewheel scrolling, it is difficult for web developers to guarantee a well-controlled scrolling experience, in particular creating the effect of paging through content. For instance, it is easy for a user to land at an awkward scroll position which leaves a page partially on-screen when panning.

To this end, we introduce scroll snap positions which enforce the scroll positions that a scroll container’s scrollport may end at after a scrolling operation has completed.

1.1. Module interactions

This module extends the scrolling user interface features defined in [CSS21] section 11.1.

None of the properties in this module apply to the ::first-line and ::first-letter pseudo-elements.

1.2. Values

This specification follows the CSS property definition conventions from [CSS21]. Value types not defined in this specification are defined in CSS Level 2 Revision 1 [CSS21]. Other CSS modules may expand the definitions of these value types: for example [CSS3VAL], when combined with this module, expands the definition of the <length> value type as used in this specification.

2. Motivating Examples

In this example, a series of images arranged in a scroll container are used to build a photo gallery. In this example the scroll container is larger than the photos contained within (such that multiple images may be seen simultaneously), and the image sizes vary. Using mandatory element-based snap positions, scrolling will always complete with an image centered in the scroll container’s scrollport.
img {
    /* Specifies that the center of each photo
       should align with the center of the scroll
       container in the X axis when snapping */
    scroll-snap-align: center none;
}
.photoGallery {
    width: 500px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    /* Requires that the scroll position always be
       at a snap position when the scrolling
       operation completes. */
    scroll-snap-type: mandatory;
}
<div class="photoGallery">
    <img src="img1.jpg">
    <img src="img2.jpg">
    <img src="img3.jpg">
    <img src="img4.jpg">
    <img src="img5.jpg">
</div>
The layout of the scroll container’s contents in the example. The snapport is represented by the red rectangle, and the snap area is represented by the yellow rectangle. Since the scroll-snap-align is “center” in the X axis, a snap position is established at each scroll position which aligns the X-center of the snapport (represented by a red dotted line) with the X-center of a snap area (represented by a yellow dotted line).
This example builds a paginated document that aligns each page near to (but not exactly on) the edge of the scroll container. This allows the previous page to “peek” in from above in order to make the user aware that they are not yet at the top of the document. Using proximity snap positions instead of mandatory snap positions allows the user to stop halfway through a page (rather than forcing them to snap one page at a time). However, if a scrolling operation would finish near a snap position, then the scroll will be adjusted to align the page as specified.
.page {
    /* Defines the top of each page as the
       edge that should be used for snapping */
    scroll-snap-align: none start;
}
.docScroller {
    width: 500px;
    overflow-x: hidden;
    overflow-y: auto;
    /* Specifies that each element’s snap area should
       align with a 100px offset from the top edge. */
    scroll-padding: 100px 0 0;
    /* Encourages scrolling to end at a snap position when the
        operation completes, if it is near a snap position */
    scroll-snap-type: proximity;
}
<div class="docScroller">
    <div class="page">Page 1</div>
    <div class="page">Page 2</div>
    <div class="page">Page 3</div>
    <div class="page">Page 4</div>
</div>
The layout of the scroll container’s contents in the example. The snapport is represented by the red rectangle (inset from the top by 100px due to the scroll-padding), and the snap area is represented by the yellow rectangle. Since the scroll-snap-align is “start” in the Y axis, a snap position is established at each scroll position which aligns the Y-start of the snapport (represented by a red dotted line) with the Y-start of a snap area (represented by a yellow dotted line).

3. Overview

This module introduces control over scroll snap positions, which are scroll positions that produce particular alignments of content within a scroll container. Using the scroll-snap-type property on the relevant scroll container, the author can request a particular bias for the scrollport to land on a snap position after scrolling operations.

Snap positions are specified as a particular alignment (scroll-snap-align) of an element’s scroll snap area (its border bounding box, as modified by scroll-snap-margin) within the scroll container’s snapport (its scrollport, as reduced by scroll-padding). This is conceptually equivalent to specifying the alignment of an alignment subject within an alignment container. A scroll position that satisfies the specified alignment is a snap position.

The act of adjusting the scroll position of a scroll container’s scrollport such that it is aligned to a snap position is called snapping, and a scroll container is said to be snapped to a snap position if its scrollport’s scroll position is that snap position and there is no active scrolling operation. The CSS Scroll Snap Module intentionally does not specify nor mandate any precise animations or physics used to enforce snap positions; this is left up to the user agent.

Snap positions only affect the nearest ancestor scroll container on the element’s containing block chain.

4. Capturing Scroll Snap Areas: Properties on the scroll container

4.1. Scroll Snapping Rules: the scroll-snap-type property

Name: scroll-snap-type
Value: none | [ x | y | block | inline | both ] [ mandatory | proximity ]?
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified
Animatable: no

The scroll-snap-type property specifies whether a scroll container is a scroll snap container, how strictly it snaps, and which axes are considered. If no strictness value is specified, proximity is assumed.

4.1.1. Scroll Snap Axis: the x, y, block, inline, and both values

The axis values specify what axis(es) are affected by snap positions, and whether snap positions are evaluated independently per axis, or together as a 2D point. Values are defined as follows:

x
The scroll container snaps to snap positions in its horizontal axis only.
y
The scroll container snaps to snap positions in its vertical axis only.
block
The scroll container snaps to snap positions in its block axis only.
inline
The scroll container snaps to snap positions in its inline axis only.
both
The scroll container snaps to snap positions in both of its axes independently (potentially snapping to different elements in each axis).

4.1.2. Scroll Snap Strictness: the none, proximity, and mandatory values

The strictness values (none, proximity, mandatory) specify how strictly snap positions are enforced on the scroll container (by forcing an adjustment to the scroll position). Values are defined as follows:

none
If specified on a scroll container, the scroll container must not snap.
mandatory
If specified on a scroll container, the scroll container is required to be snapped to a snap position when there are no active scrolling operations. If a reachable snap position exists then the scroll container must snap at the termination of a scroll (if none exist then no snapping occurs).
proximity
If specified on a scroll container, the scroll container may snap to a snap position at the termination of a scroll, at the discretion of the UA given the parameters of the scroll.
Authors should use mandatory snap positions with consideration of varyingly-sized screens and (if applicable) varying-sized content. In particular, although access to snapped elements larger than the scrollport is handled by the UA, if authors assign mandatory snapping to non-adjacent siblings, content in between can become inaccessible in cases where it is longer than the screen.

A box captures snap positions if it is a scroll container or has a value other than none for scroll-snap-type. If a box’s nearest snap-position capturing ancestor on its containing block chain is a scroll container with a non-none value for scroll-snap-type, that is the box’s scroll snap container. Otherwise, the box has no scroll snap container, and its snap positions do not trigger snapping.

If the content or layout of the document changes (e.g. content is added, moved, deleted, resized) such that the content of a snapport changes, the UA must re-evaluate the resulting scroll position, and re-snap if required. If the scroll container was snapped before the content change and that same snap position still exists (e.g. its associated element was not deleted), the scroll container must be re-snapped to that same snap position after the content change.

4.2. Scroll Snapport: the scroll-padding property

Name: scroll-padding
Value: [ <length> | <percentage> ]{1,4}
Initial: 0
Applies to: scroll containers
Inherited: no
Percentages: relative to the corresponding dimension of the scroll container’s scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

The scroll-padding property defines the optimal viewing region of the scrollport, the region used as the target region for placing things in view of the user. It allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or simply to put more breathing room between a targetted element and the edges of the scrollport.

The scroll-padding effectively reduces the region of the viewport that is considered “viewable” for scrolling operations: it has no effect on layout, on the scroll origin or initial position, or on whether or not an element is considered actually visible, but it should affect whether an element or the caret is considered scrolled into view, and reduce the amount of scrolling for paging operations (such as using the PgUp and PgDn keys or triggering equivalent operations from the scrollbar) so that within the optimal viewing region of the scrollport the user sees a continuous stream of content.

For a scroll snap container this region also defines the scroll snapportthe area of the scrollport that is used as the alignment container for the scroll snap areas when calculating snap positions.

Values are interpreted as for padding, and specify inward offsets from each edge of the scrollport.

In this example, scroll-padding is used to center slideshow images within the portion of the scrollport that is not obscured by a fixed-position toolbar.
body {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: mandatory;
    scroll-padding: 0 500px 0 0;
}
.toolbar {
    position: fixed;
    height: 100%;
    width: 500px;
    right: 0;
}
img {
    scroll-snap-align: center none;
}

This property is a shorthand property that sets all of the scroll-padding-* longhands in one declaration.

5. Aligning Scroll Snap Areas: Properties on the elements

5.1. Scroll Snapping Area: the scroll-snap-margin property

Name: scroll-snap-margin
Value: <length>{1,4}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length

The scroll-snap-margin property defines the scroll snap area that is used for snapping this box to the snapport. The <length> values give outsets (interpreted as for margin or border-image-outset). The scroll snap area is the rectangular bounding box of the transformed border box, plus the specified outsets, axis-aligned in the scroll container’s coordinate space.

Note: This ensures that the scroll snap area is always rectangular and axis-aligned to the scroll container’s coordinate space.

This property is a shorthand property that sets all of the scroll-snap-margin-* longhands in one declaration.

5.2. Scroll Snapping Alignment: the scroll-snap-align property

Name: scroll-snap-align
Value: [ none | start | end | center ]{1,2}
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: two keywords
Animatable: no

The scroll-snap-align property specifies the box’s snap position as an alignment of its snap area (as the alignment subject) within its snap container’s snapport (as the alignment container). The two values specify the snapping alignment in the inline axis and block axis, respectively. If only one value is specified, the second value defaults to the same value.

Values are defined as follows:

none
This box does not define a snap position in the specified axis.
start
Start alignment of this box’s scroll snap area within the scroll container’s snapport is a snap position in the specified axis.
end
End alignment of this box’s scroll snap area within the scroll container’s snapport is a snap position in the specified axis.
center
Center alignment of this box’s scroll snap area within the scroll container’s snapport is a snap position in the specified axis.

5.2.1. Scoping Valid Snap Positions to Visible Boxes

Since the purpose of scroll snapping is to align content within the viewport for optimal viewing, a scroll container cannot be snapped to a snap area if no part of it is within the snapport. For example, a snap area is top-aligned to the snapport if its top edge is coincident with the snapport’s top edge; however, this scroll position is nonetheless not a valid snap position if the entire snap area is outside the snapport (because the required alignment, though satisfied, would not be relevant to the viewer).

╔════viewport════╗┈┈┈┈┈┈┈┈┌──────────────┐
║  ┌─────┐ ┌──┐  ║        │ top-snapping │
║  ├──┐  │ └──┘  ║        │   element    │
║  └──┴──┘       ║        │              │
╚════════════════╝        │              │
                          └──────────────┘
Alignment of an off-screen element is not considered snapping.
Why limit snapping to only when the element is visible? As the WebKit implementers point out, extending a snap edge infinitely across the canvas only allows for snapping gridded layouts, and produces odd behavior for the user when off-screen elements do not align with on-screen elements. (If this requirement is onerous for implementers however, we can default to a gridded behavior and introduce a switch to get smarter behavior later.)

5.2.2. Snapping Boxes that Overflow the Scrollport

If the snap area is larger than the snapport in a particular axis, then any scroll position in which the snap area covers the snapport, and the distance between the geometrically previous and subsequent snap positions in that axis is larger than size of the snapport in that axis, is a valid snap position in that axis. The UA may use the specified alignment as a more precise target for certain scroll operations (e.g. explicit paging).

For example, take the first example in §2 Motivating Examples, which had a photo as the area. The author wants mandatory snapping from item to item, but if the item happens to be larger than your viewport, you want to be able to scroll around the whole thing once you’re over it.

Since the snap area is larger than the snapport, while the area fully fills the viewport, the container can be scrolled arbitrarily and will not try to snap back to its aligned position. However, if the container is scrolled such that the area no longer fully fills the viewport in an axis, the area resists outward scrolling until it is scrolled sufficiently to trigger snapping to a different snap position.

For another example, mandatory top-snapping on nested section elements can produce large snapping areas (from large top-level sections) potentially filled with smaller snapping areas (from the subsections). When the subsections are small enough, they snap normally; when they’re longer, the viewer can scroll arbitrarily within them, or within a large segment of the top-level section that has no subsections to snap to.
┌─ top-level section ─┐ ━┓
│                     │ 1┃
│                     │  ┃
│                     │ ━┩
│                     │  ┆
│                     │  ┆
│┌─── sub-section ───┐│  ╯ ━┓
│└───────────────────┘│    2┃
│┌─── sub-section ───┐│ ━┓  ┃
││                   ││ 3┃ ━┛
│└───────────────────┘│  ┃
│┌─── sub-section ───┐│ ━┛ ━┓
│└───────────────────┘│    4┃
│┌─── sub-section ───┐│ ━┓  ┃
││                   ││ 5┃ ━┛
││                   ││  ┃
││                   ││ ━┩
││                   ││  ┆
││                   ││  ┆
││                   ││  ┆
│└───────────────────┘│  ┆
└─────────────────────┘  ╯
In the figure above, the five numbered viewports represent the five snap positions associated with the top-level section and its four subsections. Because the first and last snap positions are part of ranges taller than the viewport, the viewer is allowed to scroll freely between the top and bottom of each range.

Note: If the author had instead set mandatory snap positions on the headings of each section (rather than the sections themselves), the contents of the first and fifth sections would be partially inaccessible to the user, as the heading snap area does not extend to cover the whole section.

5.2.3. Unreachable Snap Positions

If a snap position is unreachable as specified, such that aligning to it would require scrolling the scroll container’s viewport past the edge of its scrollable overflow region, the used snap position for this snap area is the position resulting from scrolling as much as possible in each relevant axis toward the desired snap position.

5.3. Scroll Snap Limits: the scroll-snap-stop property

Name: scroll-snap-stop
Value: normal | always
Initial: normal
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified
Animatable: no

This property specifies whether the scroll container must stop at each snap position it passes, or may pass multiple snap positions before coming to rest. Values are defined as follows:

normal
The scroll container may pass by a snap position defined by this element during the execution of a scrolling operation.
always
The scroll container must not pass by a snap position defined by this element during the execution of a scrolling operation.

6. Snapping Mechanics

The precise model algorithm to select a snap position to snap to is intentionally left mostly undefined, so that user agents can take into account sophisticated models of user intention and interaction and adjust how they respond over time, to best serve the user.

This section defines some useful concepts to aid in discussing scroll-snapping mechanics, and provides some guidelines for what an effective scroll-snapping strategy might look like. User agents are encouraged to adapt this guidance and apply their own best judgement when defining their own snapping behavior. It also provides a small number of behavior requirements, to ensure a minimum reasonable behavior that authors can depend on when designing their interfaces with scroll-snapping in mind.

6.1. Types of Scrolling Methods

When a page is scrolled, the action is performed with an intended end position and/or an intended direction. Each combination of these two things defines a distinct category of scrolling, which can be treated slightly differently:

intended end position

Common examples of scrolls with only an intended end position include:
  • a panning gesture, released without momentum

  • manipulating the scrollbar “thumb” explicitly

  • programmatically scrolling via APIs such as scrollTo()

  • tabbing through the document’s focusable elements

  • navigating to an anchor within the page

intended direction and end position

Common examples of scrolls with both an intended direction and end position include:
  • a “fling” gesture, interpreted with momentum

  • programmatically scrolling via APIs such as scrollBy()

The intended end point of the scroll prior to intervention from features such as snap points is its natural end-point.

intended direction

Common examples of scrolls with only an intended direction include:
  • pressing an arrow key on the keyboard

  • a swiping gesture interpreted as a fixed (rather than inertial) scroll

Additionally, because page layouts usually align things vertically and/or horizontally, UAs sometimes axis-lock a scroll when its direction is sufficiently vertical or horizontal. An axis-locked scroll is bound to only scroll along that axis. This prevents less-precise input mechanisms from drifting in the non-primary axis.

6.2. Choosing Snap Positions

A scroll container can have many snap areas scattered throughout its scrollable overflow region. A naïve algorithm for selecting a snap position can produce behavior that is unintuitive for users, so care is required when designing a selection algorithm. Here are a few pointers that can aid in the selection process:

Appendix A: Longhands

Physical Longhands for scroll-padding

Name: scroll-padding-top, scroll-padding-right, scroll-padding-bottom, scroll-padding-left
Value: <length> | <percentage>
Initial: 0
Applies to: scroll containers
Inherited: no
Percentages: relative to the scroll container’s scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

These longhands of scroll-padding specify the top, right, bottom, and left edges of the snapport, respectively.

Flow-relative Longhands for scroll-padding

Name: scroll-padding-inline-start, scroll-padding-block-start, scroll-padding-inline-end, scroll-padding-block-end
Value: <length> | <percentage>
Initial: 0
Applies to: scroll containers
Inherited: no
Percentages: relative to the scroll container’s scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

These longhands of scroll-padding specify the block-start, inline-start, block-end, and inline-end edges of the snapport, respectively.

Name: scroll-padding-block, scroll-padding-inline
Value: [ <length> | <percentage> ]{1,2}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: relative to the scroll container’s scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

These shorthands of scroll-padding-block-start + scroll-padding-block-end and scroll-padding-inline-start + scroll-padding-inline-end are longhands of scroll-padding, and specify the block-axis and inline-axis edges of the snapport, respectively.

If two values are specified, the first gives the start value and the second gives the end value.

Physical Longhands for scroll-snap-margin

Name: scroll-snap-margin-top, scroll-snap-margin-right, scroll-snap-margin-bottom, scroll-snap-margin-left
Value: <length>
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length

These longhands of scroll-snap-margin specify the top, right, bottom, and left edges of the scroll snap area, respectively.

Flow-relative Longhands for scroll-snap-margin

Name: scroll-snap-margin-block-start, scroll-snap-margin-inline-start, scroll-snap-margin-block-end, scroll-snap-margin-inline-end
Value: <length>
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length

These longhands of scroll-snap-margin specify the block-start, inline-start, block-end, and inline-end edges of the scroll snap area, respectively.

Name: scroll-snap-margin-block, scroll-snap-margin-inline
Value: <length>{1,2}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length

These shorthands of scroll-snap-margin-block-start + scroll-snap-margin-block-end and scroll-snap-margin-inline-start + scroll-snap-margin-inline-end are longhands of scroll-snap-margin, and specify the block-axis and inline-axis edges of the scroll snap area, respectively.

If two values are specified, the first gives the start value and the second gives the end value.

7. Privacy and Security Considerations

This specification does not expose any information whatsoever that is not already exposed to the DOM directly; it just makes scrolling slightly more functional. There are no new privacy or security considerations.

8. Acknowledgements

Many thanks to David Baron, Simon Fraser, Håkon Wium Lie, Edward O’Connor, François Remy, Majid Valpour, and most especially Robert O’Callahan for their proposals and recommendations, which have been incorporated into this document.

9. Changes

Changes since the 23 June 2016 Working Draft include:

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 https://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

CR exit criteria

For this specification to be advanced to Proposed Recommendation, there must be at least two independent, interoperable implementations of each feature. Each feature may be implemented by a different set of products, there is no requirement that all features be implemented by a single product. For the purposes of this criterion, we define the following terms:

independent
each implementation must be developed by a different party and cannot share, reuse, or derive from code used by another qualifying implementation. Sections of code that have no bearing on the implementation of this specification are exempt from this requirement.
interoperable
passing the respective test case(s) in the official CSS test suite, or, if the implementation is not a Web browser, an equivalent test. Every relevant test in the test suite should have an equivalent test created if such a user agent (UA) is to be used to claim interoperability. In addition if such a UA is to be used to claim interoperability, then there must one or more additional UAs which can also pass those equivalent tests in the same way for the purpose of interoperability. The equivalent tests must be made publicly available for the purposes of peer review.
implementation
a user agent which:
  1. implements the specification.
  2. is available to the general public. The implementation may be a shipping product or other publicly available version (i.e., beta version, preview release, or "nightly build"). Non-shipping product releases must have implemented the feature(s) for a period of at least one month in order to demonstrate stability.
  3. is not experimental (i.e., a version specifically designed to pass the test suite and is not intended for normal usage going forward).

The specification will remain Candidate Recommendation for at least six months.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-ALIGN-3]
Elika Etemad; Tab Atkins Jr.. CSS Box Alignment Module Level 3. 14 June 2016. WD. URL: https://www.w3.org/TR/css-align-3/
[CSS-BACKGROUNDS-3]
CSS Backgrounds and Borders Module Level 3 URL: https://www.w3.org/TR/css3-background/
[CSS-CASCADE-3]
Elika Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 3. 19 May 2016. CR. URL: https://www.w3.org/TR/css-cascade-3/
[CSS-DISPLAY-3]
Tab Atkins Jr.; Elika Etemad. CSS Display Module Level 3. 15 October 2015. WD. URL: https://www.w3.org/TR/css-display-3/
[CSS-OVERFLOW-3]
David Baron; Florian Rivoal. CSS Overflow Module Level 3. 31 May 2016. WD. URL: https://www.w3.org/TR/css-overflow-3/
[CSS-PSEUDO-4]
Daniel Glazman; Elika Etemad; Alan Stearns. CSS Pseudo-Elements Module Level 4. 7 June 2016. WD. URL: https://www.w3.org/TR/css-pseudo-4/
[CSS-WRITING-MODES-3]
Elika Etemad; Koji Ishii. CSS Writing Modes Level 3. 15 December 2015. CR. URL: https://www.w3.org/TR/css-writing-modes-3/
[CSS21]
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/CSS2
[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/
[CSS3VAL]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. 29 September 2016. CR. URL: https://www.w3.org/TR/css-values-3/
[CSSOM-VIEW-1]
Simon Pieters. CSSOM View Module. 17 March 2016. WD. URL: https://www.w3.org/TR/cssom-view-1/
[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
[SELECTORS-4]
Selectors Level 4 URL: https://www.w3.org/TR/selectors4/

Informative References

[HTML]
Ian Hickson. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/

Property Index

Name Value Initial Applies to Inh. %ages Media Ani­mat­able Com­puted value
scroll-snap-type none | [ x | y | block | inline | both ] [ mandatory | proximity ]? none all elements no n/a interactive no as specified
scroll-padding [ <length> | <percentage> ]{1,4} 0 scroll containers no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-margin <length>{1,4} 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-align [ none | start | end | center ]{1,2} none all elements no n/a interactive no two keywords
scroll-snap-stop normal | always normal all elements no n/a interactive no as specified
scroll-padding-top <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-right <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-bottom <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-left <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-inline-start <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-block-start <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-inline-end <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-block-end <length> | <percentage> 0 scroll containers no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-block [ <length> | <percentage> ]{1,2} 0 all elements no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-inline [ <length> | <percentage> ]{1,2} 0 all elements no relative to the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-margin-top <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-right <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-bottom <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-left <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-block-start <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-inline-start <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-block-end <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-inline-end <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-block <length>{1,2} 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-inline <length>{1,2} 0 all elements no n/a interactive as length as specified, with lengths made absolute