CSSOM View Module

Editor’s Draft,

More details about this document
This version:
https://drafts.csswg.org/cssom-view/
Latest published version:
https://www.w3.org/TR/cssom-view-1/
Previous Versions:
Feedback:
CSSWG Issues Repository
Inline In Spec
Editors:
(Apple Inc)
(Mozilla)
Former Editors:
(Opera Software AS)
Glenn Adams (Cox Communications, Inc.)
Anne van Kesteren (Opera Software ASA)
Suggest an Edit for this Spec:
GitHub Editor
Legacy issues list:
Bugzilla

Abstract

The APIs introduced by this specification provide authors with a way to inspect and manipulate the visual view of a document. This includes getting the position of element layout boxes, obtaining the width of the viewport through script, and also scrolling an element.

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.

Please send feedback by filing issues in GitHub (preferred), including the spec code “cssom-view” in the title, like this: “[cssom-view] …summary of comment…”. All issues and comments are archived. Alternately, feedback can be sent to the (archived) public mailing list [email protected].

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

1. Background

Many of the features defined in this specification have been supported by browsers for a long period of time. The goal of this specification is to define these features in such a way that they can be implemented by all browsers in an interoperable manner. The specification also defines a some new features which allow for scroll customization.

2. Terminology

Terminology used in this specification is from DOM, CSSOM and HTML. [DOM] [CSSOM] [HTML]

An element body (which will be the body element) is potentially scrollable if all of the following conditions are true:

Note: A body element that is potentially scrollable might not have a scrolling box. For instance, it could have a used value of overflow being auto but not have its content overflowing its content area.

A scrolling box of a viewport or element has two overflow directions, which are the block-end and inline-end directions for that viewport or element. Note that the initial scroll position might not be aligned with the scrolling area origin depending on the content-distribution properties, see CSS Box Alignment 3 § 5.3 Overflow and Scroll Positions.

The term scrolling area refers to a box of a viewport or an element that has the following edges, depending on the viewport’s or element’s scrolling box’s overflow directions.

If the overflow directions are… For a viewport For an element
rightward and downward
top edge
The top edge of the initial containing block.
right edge
The right-most edge of the right edge of the initial containing block and the right margin edge of all of the viewport’s descendants' boxes.
bottom edge
The bottom-most edge of the bottom edge of the initial containing block and the bottom margin edge of all of the viewport’s descendants' boxes.
left edge
The left edge of the initial containing block.
top edge
The element’s top padding edge.
right edge
The right-most edge of the element’s right padding edge and the right margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
bottom edge
The bottom-most edge of the element’s bottom padding edge and the bottom margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
left edge
The element’s left padding edge.
leftward and downward
top edge
The top edge of the initial containing block.
right edge
The right edge of the initial containing block.
bottom edge
The bottom-most edge of the bottom edge of the initial containing block and the bottom margin edge of all of the viewport’s descendants' boxes.
left edge
The left-most edge of the left edge of the initial containing block and the left margin edge of all of the viewport’s descendants' boxes.
top edge
The element’s top padding edge.
right edge
The element’s right padding edge.
bottom edge
The bottom-most edge of the element’s bottom padding edge and the bottom margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
left edge
The left-most edge of the element’s left padding edge and the left margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
leftward and upward
top edge
The top-most edge of the top edge of the initial containing block and the top margin edge of all of the viewport’s descendants' boxes.
right edge
The right edge of the initial containing block.
bottom edge
The bottom edge of the initial containing block.
left edge
The left-most edge of the left edge of the initial containing block and the left margin edge of all of the viewport’s descendants' boxes.
top edge
The top-most edge of the element’s top padding edge and the top margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
right edge
The element’s right padding edge.
bottom edge
The element’s bottom padding edge.
left edge
The left-most edge of the element’s left padding edge and the left margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
rightward and upward
top edge
The top-most edge of the top edge of the initial containing block and the top margin edge of all of the viewport’s descendants' boxes.
right edge
The right-most edge of the right edge of the initial containing block and the right margin edge of all of the viewport’s descendants' boxes.
bottom edge
The bottom edge of the initial containing block.
left edge
The left edge of the initial containing block.
top edge
The top-most edge of the element’s top padding edge and the top margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
right edge
The right-most edge of the element’s right padding edge and the right margin edge of all of the element’s descendants' boxes, excluding boxes that have an ancestor of the element as their containing block.
bottom edge
The element’s bottom padding edge.
left edge
The element’s left padding edge.

The origin of a scrolling area is the origin of the initial containing block if the scrolling area is a viewport, and otherwise the top left padding edge of the element when the element has its default scroll position. The x-coordinate increases rightwards, and the y-coordinate increases downwards.

The beginning edges of a particular set of edges of a box or element are the following edges:

If the overflow directions are rightward and downward
The top and left edges.
If the overflow directions are leftward and downward
The top and right edges.
If the overflow directions are leftward and upward
The bottom and right edges.
If the overflow directions are rightward and upward
The bottom and left edges.

The ending edges of a particular set of edges of a box or element are the following edges:

If the overflow directions are rightward and downward
The bottom and right edges.
If the overflow directions are leftward and downward
The bottom and left edges.
If the overflow directions are leftward and upward
The top and left edges.
If the overflow directions are rightward and upward
The top and right edges.

The visual viewport is a kind of viewport whose scrolling area is another viewport, called the layout viewport.

In addition to scrolling, the visual viewport may also apply a scale transform to its layout viewport. This transform is applied to the canvas of the layout viewport and does not affect its internal coordinate space.

Note: The scale transform of the visual viewport is often referred to as "pinch-zoom". Conceptually, this transform changes the size of the CSS reference pixel but changes the size of the layout viewport proportionally so that it does not cause reflow of the page’s contents.

The magnitude of the scale transform is known as the visual viewport’s scale factor.

This animation shows an example of a zoomed in visual viewport being "panned" around (for example, by a user performing a touch drag). The page is scaled so that the layout viewport is larger than the visual viewport.

A scroll delta is applied to the visual viewport first. When the visual viewport is at its extent, scroll delta will be applied to the layout viewport. This behavior is implemented by the perform a scroll steps.

Document Layout Viewport Visual Viewport

The VisualViewport object has an associated document, which is a Document object. It is the associated document of the owner Window of VisualViewport. The layout viewport is the owner Window's viewport.

For the purpose of the requirements in this specification, elements that have a computed value of the display property that is table-column or table-column-group must be considered to have an associated box (the column or column group, respectively).

The term SVG layout box refers to a box generated by an SVG element which does not correspond to a CSS-defined display type. (Such as the box generated by a rect element.)

The term transforms refers to SVG transforms and CSS transforms. [SVG11] [CSS-TRANSFORMS-1]

When a method or an attribute is said to call another method or attribute, the user agent must invoke its internal API for that attribute or method so that e.g. the author can’t change the behavior by overriding attributes or methods with custom properties or functions in ECMAScript.

Unless otherwise stated, all string comparisons use is.

2.1. CSS pixels

All coordinates and dimensions for the APIs defined in this specification are in CSS pixels, unless otherwise specified. [CSS-VALUES]

Note: This does not apply to e.g. matchMedia() as the units are explicitly given there.

2.2. Zooming

There are two kinds of zoom, page zoom which affects the size of the initial viewport, and the visual viewport scale factor which acts like a magnifying glass and does not affect the initial viewport or actual viewport. [CSS-DEVICE-ADAPT]

Note: The "scale factor" is often referred to as "pinch-zoom"; however, it can be affected through means other than pinch-zooming. e.g. The user agent may zooms in on a focused input element to make it legible.

2.3. Web-exposed screen information

User agents may choose to hide information about the screen of the output device, in order to protect the user’s privacy. In order to do so in a consistent manner across APIs, this specification defines the following terms, each having a width and a height, the origin being the top left corner, and the x- and y-coordinates increase rightwards and downwards, respectively.

The Web-exposed screen area is one of the following:

The Web-exposed available screen area is one of the following:

3. Common Infrastructure

This specification depends on the WHATWG Infra standard. [INFRA]

3.1. Scrolling

When a user agent is to perform a scroll of a scrolling box box, to a given position position, an associated element or pseudo-element element and optionally a scroll behavior behavior (which is "auto" if omitted), the following steps must be run:

  1. Abort any ongoing smooth scroll for box.
  2. If the user agent honors the scroll-behavior property and one of the following are true:
    • behavior is "auto" and element is not null and its computed value of the scroll-behavior property is smooth
    • behavior is smooth
    ...then perform a smooth scroll of box to position. Once the position has finished updating, emit the scrollend event. Otherwise, perform an instant scroll of box to position. After an instant scroll emit the scrollend event.

    Note: behavior: "instant" always performs an instant scroll by this algorithm.

    Note: If the scroll position did not change as a result of the user interaction or programmatic invocation, where no translations were applied as a result, then no scrollend event fires because no scrolling occurred.

When a user agent is to perform a scroll of a viewport to a given position position and optionally a scroll behavior behavior (which is "auto" if omitted) it must perform a coordinated viewport scroll by following these steps:

  1. Let doc be the viewport’s associated Document.

  2. Let vv be the VisualViewport whose associated document is doc.

  3. Let maxX be the difference between viewport’s scrolling box’s width and the value of vv’s width attribute.

  4. Let maxY be the difference between viewport’s scrolling box’s height and the value of vv’s height attribute.

  5. Let dx be the horizontal component of position - the value vv’s pageLeft attribute

  6. Let dy be the vertical component of position - the value of vv’s pageTop attribute

  7. Let visual x be the value of vv’s offsetLeft attribute.

  8. Let visual y be the value of vv’s offsetTop attribute.

  9. Let visual dx be min(maxX, max(0, visual x + dx)) - visual x.

  10. Let visual dy be min(maxY, max(0, visual y + dy)) - visual y.

  11. Let layout dx be dx - visual dx

  12. Let layout dy be dy - visual dy

  13. Let element be doc’s root element if there is one, null otherwise.

  14. Perform a scroll of the viewport’s scrolling box to its current scroll position + (layout dx, layout dy) with element as the associated element, and behavior as the scroll behavior.

  15. Perform a scroll of vv’s scrolling box to its current scroll position + (visual dx, visual dy) with element as the associated element, and behavior as the scroll behavior.

Note: Conceptually, the visual viewport is scrolled until it "bumps up" against the layout viewport edge and then "pushes" the layout viewport by applying the scroll delta to the layout viewport. However, the scrolls in the steps above are computed ahead of time and applied in the opposite order so that the layout viewport is scrolled before the visual viewport. This is done for historical reasons to ensure consistent scroll event ordering. See the example above for a visual depiction.

The user pinch-zooms into the document and ticks their mouse wheel, requesting the user agent scroll the document down by 50px. Because the document is pinch-zoomed in, the visual viewport has 20px of room to scroll. The user agent distributes the scroll by scrolling the visual viewport down by 20px and the layout viewport by 30px.
The user is viewing a document in a mobile user agent. The document focuses an offscreen text input element, showing a virtual keyboard which shrinks the visual viewport. The user agent must now bring the element into view in the visual viewport. The user agent scrolls the layout viewport so that the element is visible within it, then the visual viewport so that the element is visible to the user.

Scroll is completed when the scroll position has no more pending updates or translations and the user has completed their gesture. Scroll position updates include smooth or instant mouse wheel scrolling, keyboard scrolling, scroll-snap events, or other APIs and gestures which cause the scroll position to update and possibly interpolate. User gestures like touch panning or trackpad scrolling aren’t complete until pointers or keys have released.

When a user agent is to perform a smooth scroll of a scrolling box box to position, it must update the scroll position of box in a user-agent-defined fashion over a user-agent-defined amount of time. When the scroll is completed, the scroll position of box must be position. The scroll can also be aborted, either by an algorithm or by the user.

When a user agent is to perform an instant scroll of a scrolling box box to position, it must update the scroll position of box to position.

To scroll to the beginning of the document for a document document, follow these steps:

  1. Let viewport be the viewport that is associated with document.
  2. Let position be the scroll position viewport would have by aligning the beginning edges of the scrolling area with the beginning edges of viewport.
  3. If position is the same as viewport’s current scroll position, and viewport does not have an ongoing smooth scroll, abort these steps.
  4. Perform a scroll of viewport to position, and document’s root element as the associated element, if there is one, or null otherwise.

Note: This algorithm is used when navigating to the #top fragment identifier, as defined in HTML. [HTML]

3.2. WebIDL values

When asked to normalize non-finite values for a value x, if x is one of the three special floating point literal values (Infinity, -Infinity or NaN), then x must be changed to the value 0. [WEBIDL]

4. Extensions to the Window Interface

enum ScrollBehavior { "auto", "instant", "smooth" };

dictionary ScrollOptions {
    ScrollBehavior behavior = "auto";
};
dictionary ScrollToOptions : ScrollOptions {
    unrestricted double left;
    unrestricted double top;
};

partial interface Window {
    [NewObject] MediaQueryList matchMedia(CSSOMString query);
    [SameObject, Replaceable] readonly attribute Screen screen;
    [SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;

    // browsing context
    undefined moveTo(long x, long y);
    undefined moveBy(long x, long y);
    undefined resizeTo(long width, long height);
    undefined resizeBy(long x, long y);

    // viewport
    [Replaceable] readonly attribute long innerWidth;
    [Replaceable] readonly attribute long innerHeight;

    // viewport scrolling
    [Replaceable] readonly attribute double scrollX;
    [Replaceable] readonly attribute double pageXOffset;
    [Replaceable] readonly attribute double scrollY;
    [Replaceable] readonly attribute double pageYOffset;
    undefined scroll(optional ScrollToOptions options = {});
    undefined scroll(unrestricted double x, unrestricted double y);
    undefined scrollTo(optional ScrollToOptions options = {});
    undefined scrollTo(unrestricted double x, unrestricted double y);
    undefined scrollBy(optional ScrollToOptions options = {});
    undefined scrollBy(unrestricted double x, unrestricted double y);

    // client
    [Replaceable] readonly attribute long screenX;
    [Replaceable] readonly attribute long screenLeft;
    [Replaceable] readonly attribute long screenY;
    [Replaceable] readonly attribute long screenTop;
    [Replaceable] readonly attribute long outerWidth;
    [Replaceable] readonly attribute long outerHeight;
    [Replaceable] readonly attribute double devicePixelRatio;
};

When the matchMedia(query) method is invoked these steps must be run:

  1. Let parsed media query list be the result of parsing query.
  2. Return a new MediaQueryList object, with this's associated Document as the document, with parsed media query list as its associated media query list.

The screen attribute must return the Screen object associated with the Window object.

Note: Accessing screen through a WindowProxy object might yield different results when the Document is navigated.

If the associated document is fully active, the visualViewport attribute must return the VisualViewport object associated with the Window object’s associated document. Otherwise, it must return null.

Note: the VisualViewport object is only returned and useful for a window whose Document is currently being presented. If a reference is retained to a VisualViewport whose associated Document is not being currently presented, the values in that VisualViewport must not reveal any information about the browsing context.

The moveTo(x, y) method must follow these steps:

  1. Optionally, return.

  2. Let target be this's relevant global object's browsing context.

  3. If target is not an auxiliary browsing context that was created by a script (as opposed to by an action of the user), then return.

  4. Optionally, clamp x and y in a user-agent-defined manner so that the window does not move outside the available space.

  5. Move target’s window such that the window’s top left corner is at coordinates (x, y) relative to the top left corner of the output device, measured in CSS pixels of target. The positive axes are rightward and downward.

The moveBy(x, y) method must follow these steps:

  1. Optionally, return.

  2. Let target be this's relevant global object's browsing context.

  3. If target is not an auxiliary browsing context that was created by a script (as opposed to by an action of the user), then return.

  4. Optionally, clamp x and y in a user-agent-defined manner so that the window does not move outside the available space.

  5. Move target’s window x CSS pixels of target rightward and y CSS pixels of target downward.

The resizeTo(width, height) method must follow these steps:

  1. Optionally, return.

  2. Let target be this's relevant global object's browsing context.

  3. If target is not an auxiliary browsing context that was created by a script (as opposed to by an action of the user), then return.

  4. Optionally, clamp width and height in a user-agent-defined manner so that the window does not get too small or bigger than the available space.

  5. Resize target’s window by moving its right and bottom edges such that the distance between the left and right edges of the viewport are width CSS pixels of target and the distance between the top and bottom edges of the viewport are height CSS pixels of target.

  6. Optionally, move target’s window in a user-agent-defined manner so that it does not grow outside the available space.

The resizeBy(x, y) method must follow these steps:

  1. Optionally, return.

  2. Let target be this's relevant global object's browsing context.

  3. If target is not an auxiliary browsing context that was created by a script (as opposed to by an action of the user), then return.

  4. Optionally, clamp x and y in a user-agent-defined manner so that the window does not get too small or bigger than the available space.

  5. Resize target’s window by moving its right edge x CSS pixels of target rightward and its bottom edge y CSS pixels of target downward.

  6. Optionally, move target’s window in a user-agent-defined manner so that it does not grow outside the available space.

The innerWidth attribute must return the viewport width including the size of a rendered scroll bar (if any), or zero if there is no viewport.

The following snippet shows how to obtain the width of the viewport:
var viewportWidth = innerWidth

The innerHeight attribute must return the viewport height including the size of a rendered scroll bar (if any), or zero if there is no viewport.

The scrollX attribute must return the x-coordinate, relative to the initial containing block origin, of the left of the viewport, or zero if there is no viewport.

The pageXOffset attribute must return the value returned by the scrollX attribute.

The scrollY attribute must return the y-coordinate, relative to the initial containing block origin, of the top of the viewport, or zero if there is no viewport.

The pageYOffset attribute must return the value returned by the scrollY attribute.

When the scroll() method is invoked these steps must be run:

  1. If invoked with one argument, follow these substeps:

    1. Let options be the argument.

    2. Let x be the value of the left dictionary member of options, if present, or the viewport’s current scroll position on the x axis otherwise.

    3. Let y be the value of the top dictionary member of options, if present, or the viewport’s current scroll position on the y axis otherwise.

  2. If invoked with two arguments, follow these substeps:

    1. Let options be null converted to a ScrollToOptions dictionary. [WEBIDL]

    2. Let x and y be the arguments, respectively.

  3. Normalize non-finite values for x and y.

  4. If there is no viewport, abort these steps.

  5. Let viewport width be the width of the viewport excluding the width of the scroll bar, if any.

  6. Let viewport height be the height of the viewport excluding the height of the scroll bar, if any.

  7. If the viewport has rightward overflow direction
    Let x be max(0, min(x, viewport scrolling area width - viewport width)).
    If the viewport has leftward overflow direction
    Let x be min(0, max(x, viewport width - viewport scrolling area width)).
  8. If the viewport has downward overflow direction
    Let y be max(0, min(y, viewport scrolling area height - viewport height)).
    If the viewport has upward overflow direction
    Let y be min(0, max(y, viewport height - viewport scrolling area height)).
  9. Let position be the scroll position the viewport would have by aligning the x-coordinate x of the viewport scrolling area with the left of the viewport and aligning the y-coordinate y of the viewport scrolling area with the top of the viewport.

  10. If position is the same as the viewport’s current scroll position, and the viewport does not have an ongoing smooth scroll, abort these steps.

  11. Let document be the viewport’s associated Document.

  12. Perform a scroll of the viewport to position, document’s root element as the associated element, if there is one, or null otherwise, and the scroll behavior being the value of the behavior dictionary member of options.

    User agents do not agree whether this uses the (coordinated) viewport perform a scroll or the scrolling box perform a scroll on the layout viewport’s scrolling box.

When the scrollTo() method is invoked, the user agent must act as if the scroll() method was invoked with the same arguments.

When the scrollBy() method is invoked, the user agent must run these steps:

  1. If invoked with two arguments, follow these substeps:

    1. Let options be null converted to a ScrollToOptions dictionary. [WEBIDL]

    2. Let x and y be the arguments, respectively.

    3. Let the left dictionary member of options have the value x.

    4. Let the top dictionary member of options have the value y.

  2. Normalize non-finite values for the left and top dictionary members of options.

  3. Add the value of scrollX to the left dictionary member.

  4. Add the value of scrollY to the top dictionary member.

  5. Act as if the scroll() method was invoked with options as the only argument.

The screenX and screenLeft attributes must return the x-coordinate, relative to the origin of the Web-exposed screen area, of the left of the client window as number of CSS pixels, or zero if there is no such thing.

The screenY and screenTop attributes must return the y-coordinate, relative to the origin of the screen of the Web-exposed screen area, of the top of the client window as number of CSS pixels, or zero if there is no such thing.

The outerWidth attribute must return the width of the client window. If there is no client window this attribute must return zero.

The outerHeight attribute must return the height of the client window. If there is no client window this attribute must return zero.

The devicePixelRatio attribute must return the result of the following determine the device pixel ratio algorithm:

  1. If there is no output device, return 1 and abort these steps.

  2. Let CSS pixel size be the size of a CSS pixel at the current page zoom and using a scale factor of 1.0.

  3. Let device pixel size be the vertical size of a device pixel of the output device.

  4. Return the result of dividing CSS pixel size by device pixel size.

4.1. The features argument to the open() method

HTML defines the open() method. This section defines behavior for position and size given in the features argument. [HTML]

To set up browsing context features for a browsing context target given a map tokenizedFeatures:

  1. Let x be null.

  2. Let y be null.

  3. Let width be null.

  4. Let height be null.

  5. If tokenizedFeatures["left"] exists:

    1. Set x to the result of invoking the rules for parsing integers on tokenizedFeatures["left"].

    2. If x is an error, set x to 0.

    3. Optionally, clamp x in a user-agent-defined manner so that the window does not move outside the Web-exposed available screen area.

    4. Optionally, move target’s window such that the window’s left edge is at the horizontal coordinate x relative to the left edge of the Web-exposed screen area, measured in CSS pixels of target. The positive axis is rightward.

  6. If tokenizedFeatures["top"] exists:

    1. Set y to the result of invoking the rules for parsing integers on tokenizedFeatures["top"].

    2. If y is an error, set y to 0.

    3. Optionally, clamp y in a user-agent-defined manner so that the window does not move outside the Web-exposed available screen area.

    4. Optionally, move target’s window such that the window’s top edge is at the vertical coordinate y relative to the top edge of the Web-exposed screen area, measured in CSS pixels of target. The positive axis is downward.

  7. If tokenizedFeatures["width"] exists:

    1. Set width to the result of invoking the rules for parsing integers on tokenizedFeatures["width"].

    2. If width is an error, set width to 0.

    3. If width is not 0:

      1. Optionally, clamp width in a user-agent-defined manner so that the window does not get too small or bigger than the Web-exposed available screen area.

      2. Optionally, size target’s window by moving its right edge such that the distance between the left and right edges of the viewport are width CSS pixels of target.

      3. Optionally, move target’s window in a user-agent-defined manner so that it does not grow outside the Web-exposed available screen area.

  8. If tokenizedFeatures["height"] exists:

    1. Set height to the result of invoking the rules for parsing integers on tokenizedFeatures["height"].

    2. If height is an error, set height to 0.

    3. If height is not 0:

      1. Optionally, clamp height in a user-agent-defined manner so that the window does not get too small or bigger than the Web-exposed available screen area.

      2. Optionally, size target’s window by moving its bottom edge such that the distance between the top and bottom edges of the viewport are height CSS pixels of target.

      3. Optionally, move target’s window in a user-agent-defined manner so that it does not grow outside the Web-exposed available screen area.

A supported open() feature name is one of the following:

width
The width of the viewport.
height
The height of the viewport.
left
The left position of the window.
top
The top position of the window.

4.2. The MediaQueryList Interface

This section integrates with the event loop defined in HTML. [HTML]

A MediaQueryList object has an associated media query list and an associated document set on creation.

A MediaQueryList object has an associated media which is the serialized form of the associated media query list.

A MediaQueryList object has an associated matches state which is true if the associated media query list matches the state of the document, and false otherwise.

When asked to evaluate media queries and report changes for a Document doc, run these steps:

  1. For each MediaQueryList object target that has doc as its document, in the order they were created, oldest first, run these substeps:

    1. If target’s matches state has changed since the last time these steps were run, fire an event named change at target using MediaQueryListEvent, with its isTrusted attribute initialized to true, its media attribute initialized to target’s media, and its matches attribute initialized to target’s matches state.
A simple piece of code that detects changes in the orientation of the viewport can be written as follows:
function handleOrientationChange(event) {
    if(event.matches) // landscapeelse}
var mql = matchMedia("(orientation:landscape)");
mql.onchange = handleOrientationChange;
[Exposed=Window]
interface MediaQueryList : EventTarget {
  readonly attribute CSSOMString media;
  readonly attribute boolean matches;
  undefined addListener(EventListener? callback);
  undefined removeListener(EventListener? callback);
           attribute EventHandler onchange;
};

The media attribute must return the associated media.

The matches attribute must return the associated matches state.

The addListener(callback) method, when invoked, must run these steps:

  1. Add an event listener with this and an event listener whose type is change, and callback is callback.

The removeListener(callback) method, when invoked, must run these steps:

  1. If this’s event listener list contains an event listener whose type is change, callback is callback, and capture is false, then remove an event listener with this and that event listener.

Note: This specification initially had a custom callback mechanism with addListener() and removeListener(), and the callback was invoked with the associated media query list as argument. Now the normal event mechanism is used instead. For backwards compatibility, the addListener() and removeListener() methods are basically aliases for addEventListener() and removeEventListener(), respectively, and the change event masquerades as a MediaQueryList.

The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by all objects implementing the MediaQueryList interface:

Event handler Event handler event type
onchange change
[Exposed=Window]
interface MediaQueryListEvent : Event {
  constructor(CSSOMString type, optional MediaQueryListEventInit eventInitDict = {});
  readonly attribute CSSOMString media;
  readonly attribute boolean matches;
};

dictionary MediaQueryListEventInit : EventInit {
  CSSOMString media = "";
  boolean matches = false;
};

The media attribute must return the value it was initialized to.

The matches attribute must return the value it was initialized to.

4.2.1. Event summary

This section is non-normative.

Event Interface Interesting targets Description
change MediaQueryListEvent MediaQueryList Fired at the MediaQueryList when the matches state changes.

4.3. The Screen Interface

As its name suggests, the Screen interface represents information about the screen of the output device.

[Exposed=Window]
interface Screen {
  readonly attribute long availWidth;
  readonly attribute long availHeight;
  readonly attribute long width;
  readonly attribute long height;
  readonly attribute unsigned long colorDepth;
  readonly attribute unsigned long pixelDepth;
};

The availWidth attribute must return the width of the Web-exposed available screen area.

The availHeight attribute must return the height of the Web-exposed available screen area.

The width attribute must return the width of the Web-exposed screen area.

The height attribute must return the height of the Web-exposed screen area.

The colorDepth and pixelDepth attributes should return the number of bits allocated to colors for a pixel in the output device, excluding the alpha channel. If the user agent is not able to return the number of bits used by the output device, it should return the closest estimation such as, for example, the number of bits used by the frame buffer sent to the display or any internal representation that would be the closest to the value the output device would use. The user agent must return a value for these attributes at least equal to the value of the color media feature multiplied by three. If the different color components are not represented with the same number of bits, the returned value may be greater than three times the value of the color media feature. If the user agent does not know the color depth or does not want to return it for privacy considerations, it should return 24.

Note: The colorDepth and pixelDepth attributes return the same value for compatibility reasons.

Note: Some non-conforming implementations are known to return 32 instead of 24.

5. Extensions to the Document Interface

partial interface Document {
  Element? elementFromPoint(double x, double y);
  sequence<Element> elementsFromPoint(double x, double y);
  CaretPosition? caretPositionFromPoint(double x, double y, optional CaretPositionFromPointOptions options = {});
  readonly attribute Element? scrollingElement;
};

dictionary CaretPositionFromPointOptions {
  sequence<ShadowRoot> shadowRoots = [];
};

The elementFromPoint(x, y) method must follow these steps:

  1. If either argument is negative, x is greater than the viewport width excluding the size of a rendered scroll bar (if any), or y is greater than the viewport height excluding the size of a rendered scroll bar (if any), or there is no viewport associated with the document, return null and terminate these steps.

  2. If there is a box in the viewport that would be a target for hit testing at coordinates x,y, when applying the transforms that apply to the descendants of the viewport, return the associated element and terminate these steps.

  3. If the document has a root element, return the root element and terminate these steps.

  4. Return null.

Note: The elementFromPoint() method does not necessarily return the top-most painted element. For instance, an element can be excluded from being a target for hit testing by using the pointer-events CSS property.

The elementsFromPoint(x, y) method must follow these steps:

  1. Let sequence be a new empty sequence.

  2. If either argument is negative, x is greater than the viewport width excluding the size of a rendered scroll bar (if any), or y is greater than the viewport height excluding the size of a rendered scroll bar (if any), or there is no viewport associated with the document, return sequence and terminate these steps.

  3. For each box in the viewport, in paint order, starting with the topmost box, that would be a target for hit testing at coordinates x,y even if nothing would be overlapping it, when applying the transforms that apply to the descendants of the viewport, append the associated element to sequence.

  4. If the document has a root element, and the last item in sequence is not the root element, append the root element to sequence.

  5. Return sequence.

The caretPositionFromPoint(x, y, options) method must return the result of running these steps:

  1. If there is no viewport associated with the document, return null.

  2. If either argument is negative, x is greater than the viewport width excluding the size of a rendered scroll bar (if any), y is greater than the viewport height excluding the size of a rendered scroll bar (if any) return null.

  3. If at the coordinates x,y in the viewport no text insertion point indicator would have been inserted when applying the transforms that apply to the descendants of the viewport, return null.

  4. If at the coordinates x,y in the viewport a text insertion point indicator would have been inserted in a text entry widget which is also a replaced element, when applying the transforms that apply to the descendants of the viewport, return a caret position with its properties set as follows:

    caret node
    The node corresponding to the text entry widget.
    caret offset
    The amount of 16-bit units to the left of where the text insertion point indicator would have inserted.
  5. Otherwise:

    1. Let caretPosition be a tuple consisting of a caretPositionNode (a node) and a caretPositionOffset (a non-negative integer) for the position where the text insertion point indicator would have been inserted when applying the transforms that apply to the descendants of the viewport.

    2. Let startNode be the caretPositionNode of the caretPosition, and let startOffset be the caretPositionOffset of the caretPosition.

    3. While startNode is a node, startNode’s root is a shadow root, and startNode’s root is not a shadow-including inclusive ancestor of any of options["shadowRoots"], repeat these steps:

      1. Set startOffset to index of startNode’s root's host.

      2. Set startNode to startNode’s root's host's parent.

    4. Return a caret position with its properties set as follows:

      1. caret node is set to startNode.

      2. caret offset is set to startOffset.

Note: This caret position is not live.

Note: The specifics of hit testing are out of scope of this specification and therefore the exact details of elementFromPoint() and caretPositionFromPoint() are therefore too. Hit testing will hopefully be defined in a future revision of CSS or HTML.

The scrollingElement attribute, on getting, must run these steps:

  1. If the Document is in quirks mode, follow these substeps:

    1. If the body element exists, and it is not potentially scrollable, return the body element and abort these steps.

      For this purpose, a value of overflow:clip on the the body element’s parent element must be treated as overflow:hidden.

    2. Return null and abort these steps.

  2. If there is a root element, return the root element and abort these steps.

  3. Return null.

Note: For non-conforming user agents that always use the quirks mode behavior for scrollTop and scrollLeft, the scrollingElement attribute is expected to also always return the body element (or null if it does not exist). This API exists so that Web developers can use it to get the right element to use for scrolling APIs, without making assumptions about a particular user agent’s behavior or having to invoke a scroll to see which element scrolls the viewport.

Note: the body element is different from HTML’s document.body in that the latter can return a frameset element.

5.1. The CaretPosition Interface

A caret position gives the position of a text insertion point indicator. It always has an associated caret node and caret offset. It is represented by a CaretPosition object.

[Exposed=Window]
interface CaretPosition {
  readonly attribute Node offsetNode;
  readonly attribute unsigned long offset;
  [NewObject] DOMRect? getClientRect();
};

The offsetNode attribute must return the caret node.

The offset attribute must return the caret offset.

The getClientRect() method must follow these steps, aborting on the first step that returns a value:

  1. If caret node is a text entry widget that is a replaced element, and that is in the document, return a scaled DOMRect object for the caret in the widget as represented by the caret offset value. The transforms that apply to the element and its ancestors are applied.

  2. Otherwise:

    1. Let caretRange be a collapsed Range object whose start node and end node are set to caret node, and whose start offset and end offset are set to caret offset.

    2. Return the DOMRect object which is the result of invoking the getBoundingClientRect() method on caretRange.

Note: This DOMRect object is not live.

6. Extensions to the Element Interface

enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
dictionary ScrollIntoViewOptions : ScrollOptions {
  ScrollLogicalPosition block = "start";
  ScrollLogicalPosition inline = "nearest";
};

dictionary CheckVisibilityOptions {
    boolean checkOpacity = false;
    boolean checkVisibilityCSS = false;
    boolean contentVisibilityAuto = false;
    boolean opacityProperty = false;
    boolean visibilityProperty = false;
};

partial interface Element {
  DOMRectList getClientRects();
  [NewObject] DOMRect getBoundingClientRect();

  boolean checkVisibility(optional CheckVisibilityOptions options = {});

  undefined scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
  undefined scroll(optional ScrollToOptions options = {});
  undefined scroll(unrestricted double x, unrestricted double y);
  undefined scrollTo(optional ScrollToOptions options = {});
  undefined scrollTo(unrestricted double x, unrestricted double y);
  undefined scrollBy(optional ScrollToOptions options = {});
  undefined scrollBy(unrestricted double x, unrestricted double y);
  attribute unrestricted double scrollTop;
  attribute unrestricted double scrollLeft;
  readonly attribute long scrollWidth;
  readonly attribute long scrollHeight;
  readonly attribute long clientTop;
  readonly attribute long clientLeft;
  readonly attribute long clientWidth;
  readonly attribute long clientHeight;
  readonly attribute double currentCSSZoom;
};

Note: The checkOpacity and checkVisibilityCSS properties are historical names. These properties have aliases that match the new naming scheme, namely opacityProperty and visibilityProperty.

The getClientRects() method, when invoked, must return the result of the following algorithm:

  1. If the element on which it was invoked does not have an associated box return an empty DOMRectList object and stop this algorithm.

  2. If the element has an associated SVG layout box return a scaled DOMRectList object containing a single DOMRect object that describes the bounding box of the element as defined by the SVG specification, applying the transforms that apply to the element and its ancestors.

  3. Return a DOMRectList object containing DOMRect objects in content order, one for each box fragment, describing its border area (including those with a height or width of zero) with the following constraints:

    • Apply the transforms that apply to the element and its ancestors.

    • If the element on which the method was invoked has a computed value for the display property of table or inline-table include both the table box and the caption box, if any, but not the anonymous container box.

    • Replace each anonymous block box with its child box(es) and repeat this until no anonymous block boxes are left in the final list.

Note: The DOMRect objects returned by getClientRects() are not live.

The getBoundingClientRect() method, when invoked on an element element, must return the result of getting the bounding box for element.

To get the bounding box for element, run the following steps:
  1. Let list be the result of invoking getClientRects() on element.

  2. If the list is empty return a DOMRect object whose x, y, width and height members are zero.

  3. If all rectangles in list have zero width or height, return the first rectangle in list.

  4. Otherwise, return a DOMRect object describing the smallest rectangle that includes all of the rectangles in list of which the height or width is not zero.

Note: The DOMRect object returned by getBoundingClientRect() is not live.

The following snippet gets the dimensions of the first div element in a document:
var example = document.getElementsByTagName("div")[0].getBoundingClientRect();
var exampleWidth = example.width;
var exampleHeight = example.height;
Note: The checkVisibility() method provides a set of simple checks for whether an element is potentially "visible". It defaults to a very simple and straightforward method based on the box tree, but allows for several additional checks to be opted into, depending on what precise notion of "visibility" is desired.

The checkVisibility(options) method must run these steps, when called on an element this:

  1. If this does not have an associated box, return false.

  2. If an ancestor of this in the flat tree has content-visibility: hidden, return false.

  3. If either the opacityProperty or the checkOpacity dictionary members of options are true, and this, or an ancestor of this in the flat tree, has a computed opacity value of 0, return false.

  4. If either the visibilityProperty or the checkVisibilityCSS dictionary members of options are true, and this is invisible, return false.

  5. If the contentVisibilityAuto dictionary member of options is true and an ancestor of this in the flat tree skips its contents due to content-visibility: auto, return false.

  6. Return true.

The scrollIntoView(arg) method must run these steps:

  1. Let behavior be "auto".

  2. Let block be "start".

  3. Let inline be "nearest".

  4. If arg is a ScrollIntoViewOptions dictionary, then:

    1. Set behavior to the behavior dictionary member of options.

    2. Set block to the block dictionary member of options.

    3. Set inline to the inline dictionary member of options.

  5. Otherwise, if arg is false, then set block to "end".

  6. If the element does not have any associated box, or is not available to user-agent features, then return.

  7. Scroll the element into view with behavior, block, and inline.

  8. Optionally perform some other action that brings the element to the user’s attention.

The scroll() method must run these steps:

  1. If invoked with one argument, follow these substeps:

    1. Let options be the argument.

    2. Normalize non-finite values for left and top dictionary members of options, if present.

    3. Let x be the value of the left dictionary member of options, if present, or the element’s current scroll position on the x axis otherwise.

    4. Let y be the value of the top dictionary member of options, if present, or the element’s current scroll position on the y axis otherwise.

  2. If invoked with two arguments, follow these substeps:

    1. Let options be null converted to a ScrollToOptions dictionary. [WEBIDL]

    2. Let x and y be the arguments, respectively.

    3. Normalize non-finite values for x and y.

    4. Let the left dictionary member of options have the value x.

    5. Let the top dictionary member of options have the value y.

  3. Let document be the element’s node document.

  4. If document is not the active document, terminate these steps.

  5. Let window be the value of document’s defaultView attribute.

  6. If window is null, terminate these steps.

  7. If the element is the root element and document is in quirks mode, terminate these steps.

  8. If the element is the root element invoke scroll() on window with scrollX on window as first argument and y as second argument, and terminate these steps.

  9. If the element is the body element, document is in quirks mode, and the element is not potentially scrollable, invoke scroll() on window with options as the only argument, and terminate these steps.

  10. If the element does not have any associated box, the element has no associated scrolling box, or the element has no overflow, terminate these steps.

  11. Scroll the element to x,y, with the scroll behavior being the value of the behavior dictionary member of options.

When the scrollTo() method is invoked, the user agent must act as if the scroll() method was invoked with the same arguments.

When the scrollBy() method is invoked, the user agent must run these steps:

  1. If invoked with one argument, follow these substeps:

    1. Let options be the argument.

    2. Normalize non-finite values for left and top dictionary members of options, if present.

  2. If invoked with two arguments, follow these substeps:

    1. Let options be null converted to a ScrollToOptions dictionary. [WEBIDL]

    2. Let x and y be the arguments, respectively.

    3. Normalize non-finite values for x and y.

    4. Let the left dictionary member of options have the value x.

    5. Let the top dictionary member of options have the value y.

  3. Add the value of scrollLeft to the left dictionary member.

  4. Add the value of scrollTop to the top dictionary member.

  5. Act as if the scroll() method was invoked with options as the only argument.

The scrollTop attribute, on getting, must return the result of running these steps:

  1. Let document be the element’s node document.

  2. If document is not the active document, return zero and terminate these steps.

  3. Let window be the value of document’s defaultView attribute.

  4. If window is null, return zero and terminate these steps.

  5. If the element is the root element and document is in quirks mode, return zero and terminate these steps.

  6. If the element is the root element return the value of scrollY on window.

  7. If the element is the body element, document is in quirks mode, and the element is not potentially scrollable, return the value of scrollY on window.

  8. If the element does not have any associated box, return zero and terminate these steps.

  9. Return the y-coordinate of the scrolling area at the alignment point with the top of the padding edge of the element.

When setting the scrollTop attribute these steps must be run:

  1. Let y be the given value.

  2. Normalize non-finite values for y.

  3. Let document be the element’s node document.

  4. If document is not the active document, terminate these steps.

  5. Let window be the value of document’s defaultView attribute.

  6. If window is null, terminate these steps.

  7. If the element is the root element and document is in quirks mode, terminate these steps.

  8. If the element is the root element invoke scroll() on window with scrollX on window as first argument and y as second argument, and terminate these steps.

  9. If the element is the body element, document is in quirks mode, and the element is not potentially scrollable, invoke scroll() on window with scrollX as first argument and y as second argument, and terminate these steps.

  10. If the element does not have any associated box, the element has no associated scrolling box, or the element has no overflow, terminate these steps.

  11. Scroll the element to scrollLeft,y, with the scroll behavior being "auto".

The scrollLeft attribute, on getting, must return the result of running these steps:

  1. Let document be the element’s node document.

  2. If document is not the active document, return zero and terminate these steps.

  3. Let window be the value of document’s defaultView attribute.

  4. If window is null, return zero and terminate these steps.

  5. If the element is the root element and document is in quirks mode, return zero and terminate these steps.

  6. If the element is the root element return the value of scrollX on window.

  7. If the element is the body element, document is in quirks mode, and the element is not potentially scrollable, return the value of scrollX on window.

  8. If the element does not have any associated box, return zero and terminate these steps.

  9. Return the x-coordinate of the scrolling area at the alignment point with the left of the padding edge of the element.

When setting the scrollLeft attribute these steps must be run:

  1. Let x be the given value.

  2. Normalize non-finite values for x.

  3. Let document be the element’s node document.

  4. If document is not the active document, terminate these steps.

  5. Let window be the value of document’s defaultView attribute.

  6. If window is null, terminate these steps.

  7. If the element is the root element and document is in quirks mode, terminate these steps.

  8. If the element is the root element invoke scroll() on window with x as first argument and scrollY on window as second argument, and terminate these steps.

  9. If the element is the body element, document is in quirks mode, and the element is not potentially scrollable, invoke scroll() on window with x as first argument and scrollY on window as second argument, and terminate these steps.

  10. If the element does not have any associated box, the element has no associated scrolling box, or the element has no overflow, terminate these steps.

  11. Scroll the element to x,scrollTop, with the scroll behavior being "auto".

The scrollWidth attribute must return the result of running these steps:

  1. Let document be the element’s node document.

  2. If document is not the active document, return zero and terminate these steps.

  3. Let viewport width be the width of the viewport excluding the width of the scroll bar, if any, or zero if there is no viewport.

  4. If the element is the root element and document is not in quirks mode return max(viewport scrolling area width, viewport width).

  5. If the element is the body element, document is in quirks mode and the element is not potentially scrollable, return max(viewport scrolling area width, viewport width).

  6. If the element does not have any associated box return zero and terminate these steps.

  7. Return the width of the element’s scrolling area.

The scrollHeight attribute must return the result of running these steps:

  1. Let document be the element’s node document.

  2. If document is not the active document, return zero and terminate these steps.

  3. Let viewport height be the height of the viewport excluding the height of the scroll bar, if any, or zero if there is no viewport.

  4. If the element is the root element and document is not in quirks mode return max(viewport scrolling area height, viewport height).

  5. If the element is the body element, document is in quirks mode and the element is not potentially scrollable, return max(viewport scrolling area height, viewport height).

  6. If the element does not have any associated box return zero and terminate these steps.

  7. Return the height of the element’s scrolling area.

The clientTop attribute must run these steps:

  1. If the element has no associated box or if the box is inline, return zero.

  2. Return the unscaled computed value of the border-top-width property plus the height of any scrollbar rendered between the top padding edge and the top border edge, ignoring any transforms that apply to the element and its ancestors.

The clientLeft attribute must run these steps:

  1. If the element has no associated box or if the box is inline, return zero.

  2. Return the unscaled computed value of the border-left-width property plus the width of any scrollbar rendered between the left padding edge and the left border edge, ignoring any transforms that apply to the element and its ancestors.

The clientWidth attribute must run these steps:

  1. If the element has no associated box or if the box is inline, return zero.

  2. If the element is the root element and the element’s node document is not in quirks mode, or if the element is the body element and the element’s node document is in quirks mode, return the viewport width excluding the size of a rendered scroll bar (if any).

  3. Return the unscaled width of the padding edge excluding the width of any rendered scrollbar between the padding edge and the border edge, ignoring any transforms or that apply to the element and its ancestors.

The clientHeight attribute must run these steps:

  1. If the element has no associated box or if the box is inline, return zero.

  2. If the element is the root element and the element’s node document is not in quirks mode, or if the element is the body element and the element’s node document is in quirks mode, return the viewport height excluding the size of a rendered scroll bar (if any).

  3. Return the unscaled height of the padding edge excluding the height of any rendered scrollbar between the padding edge and the border edge, ignoring any transforms that apply to the element and its ancestors.

The currentCSSZoom attribute must return the effective zoom of the element, or 1.0 if the element isn’t being rendered.

6.1. Element Scrolling Members

To determine the scroll-into-view position of a target, which is an Element, pseudo-element, or Range, with a scroll behavior behavior, a block flow direction position block, an inline base direction position inline, and a scrolling box scrolling box, run the following steps:

  1. Let target bounding border box be the box represented by the return value of invoking Element’s getBoundingClientRect(), if target is an Element, or Range’s getBoundingClientRect(), if target is a Range.

  2. Let scrolling box edge A be the beginning edge in the block flow direction of scrolling box, and let element edge A be target bounding border box’s edge on the same physical side as that of scrolling box edge A.

  3. Let scrolling box edge B be the ending edge in the block flow direction of scrolling box, and let element edge B be target bounding border box’s edge on the same physical side as that of scrolling box edge B.

  4. Let scrolling box edge C be the beginning edge in the inline base direction of scrolling box, and let element edge C be target bounding border box’s edge on the same physical side as that of scrolling box edge C.

  5. Let scrolling box edge D be the ending edge in the inline base direction of scrolling box, and let element edge D be target bounding border box’s edge on the same physical side as that of scrolling box edge D.

  6. Let element height be the distance between element edge A and element edge B.

  7. Let scrolling box height be the distance between scrolling box edge A and scrolling box edge B.

  8. Let element width be the distance between element edge C and element edge D.

  9. Let scrolling box width be the distance between scrolling box edge C and scrolling box edge D.

  10. Let position be the scroll position scrolling box would have by following these steps:

    1. If block is "start", then align element edge A with scrolling box edge A.

    2. Otherwise, if block is "end", then align element edge B with scrolling box edge B.

    3. Otherwise, if block is "center", then align the center of target bounding border box with the center of scrolling box in scrolling box’s block flow direction.

    4. Otherwise, block is "nearest":

      If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B
      Do nothing.
      If element edge A is outside scrolling box edge A and element height is less than scrolling box height
      If element edge B is outside scrolling box edge B and element height is greater than scrolling box height
      Align element edge A with scrolling box edge A.
      If element edge A is outside scrolling box edge A and element height is greater than scrolling box height
      If element edge B is outside scrolling box edge B and element height is less than scrolling box height
      Align element edge B with scrolling box edge B.
    5. If inline is "start", then align element edge C with scrolling box edge C.

    6. Otherwise, if inline is "end", then align element edge D with scrolling box edge D.

    7. Otherwise, if inline is "center", then align the center of target bounding border box with the center of scrolling box in scrolling box’s inline base direction.

    8. Otherwise, inline is "nearest":

      If element edge C and element edge D are both outside scrolling box edge C and scrolling box edge D
      Do nothing.
      If element edge C is outside scrolling box edge C and element width is less than scrolling box width
      If element edge D is outside scrolling box edge D and element width is greater than scrolling box width
      Align element edge C with scrolling box edge C.
      If element edge C is outside scrolling box edge C and element width is greater than scrolling box width
      If element edge D is outside scrolling box edge D and element width is less than scrolling box width
      Align element edge D with scrolling box edge D.
    9. Return position.

To scroll a target into view target, which is an Element, pseudo-element, or Range, with a scroll behavior behavior, a block flow direction position block, and an inline base direction position inline, means to run these steps for each ancestor element or viewport that establishes a scrolling box scrolling box, in order of innermost to outermost scrolling box:
  1. If the Document associated with target is not same origin with the Document associated with the element or viewport associated with scrolling box, terminate these steps.

  2. Let position be the scroll position resulting from running the steps to determine the scroll-into-view position of target with behavior as the scroll behavior, block as the block flow position, inline as the inline base direction position and scrolling box as the scrolling box.

  3. If position is the same as scrolling box’s current scroll position, and scrolling box does not have an ongoing smooth scroll, then return.

  4. If scrolling box is associated with an element
    Perform a scroll of the element’s scrolling box to position, with the element as the associated element and behavior as the scroll behavior.
    If scrolling box is associated with a viewport
    1. Let document be the viewport’s associated Document.

    2. Let root element be document’s root element, if there is one, or null otherwise.

    3. Perform a scroll of the viewport to position, with root element as the associated element and behavior as the scroll behavior.

To scroll an element (or pseudo-element) element to x,y optionally with a scroll behavior behavior (which is "auto" if omitted) means to:

  1. Let box be element’s associated scrolling box.

  2. If box has rightward overflow direction
    Let x be max(0, min(x, element scrolling area width - element padding edge width)).
    If box has leftward overflow direction
    Let x be min(0, max(x, element padding edge width - element scrolling area width)).
  3. If box has downward overflow direction
    Let y be max(0, min(y, element scrolling area height - element padding edge height)).
    If box has upward overflow direction
    Let y be min(0, max(y, element padding edge height - element scrolling area height)).
  4. Let position be the scroll position box would have by aligning scrolling area x-coordinate x with the left of box and aligning scrolling area y-coordinate y with the top of box.

  5. If position is the same as box’s current scroll position, and box does not have an ongoing smooth scroll, abort these steps.

  6. Perform a scroll of box to position, element as the associated element and behavior as the scroll behavior.

7. Extensions to the HTMLElement Interface

partial interface HTMLElement {
  readonly attribute Element? offsetParent;
  readonly attribute long offsetTop;
  readonly attribute long offsetLeft;
  readonly attribute long offsetWidth;
  readonly attribute long offsetHeight;
};

The offsetParent attribute must return the result of running these steps:

  1. If any of the following holds true return null and terminate this algorithm:

  2. Let ancestor be the parent of the element in the flat tree and repeat these substeps:

    1. If ancestor is closed-shadow-hidden from the element and its computed value of the position property is fixed, terminate this algorithm and return null.

    2. If ancestor is not closed-shadow-hidden from the element and satisfies at least one of the following, terminate this algorithm and return ancestor.

      • ancestor is a containing block of absolutely-positioned descendants (regardless of whether there are any absolutely-positioned descendants).

      • The element has a different effective zoom than ancestor.

      • It is the body element.

      • The computed value of the position property of the element is static and the ancestor is one of the following HTML elements: td, th, or table.

    3. If there is no more parent of ancestor in the flat tree, terminate this algorithm and return null.

    4. Let ancestor be the parent of ancestor in the flat tree.

The offsetTop attribute must return the result of running these steps:

  1. If the element is the body element or does not have any associated box return zero and terminate this algorithm.

  2. If the offsetParent of the element is null return the unscaled y-coordinate of the top border edge of the first box associated with the element, relative to the initial containing block origin, ignoring any transformsthat apply to the element and its ancestors and terminate this algorithm.

  3. Return the unscaled result of subtracting the y-coordinate of the top padding edge of the first box associated with the offsetParent of the element from the y-coordinate of the top border edge of the first box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors.

    Note: An inline element that consists of multiple line boxes will only have its first box considered.

The offsetLeft attribute must return the result of running these steps:

  1. If the element is the body element or does not have any associated box return zero and terminate this algorithm.

  2. If the offsetParent of the element is null return the unscaled x-coordinate of the left border edge of the first box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors, and terminate this algorithm.

  3. Return the unscaled result of subtracting the x-coordinate of the left padding edge of the first box associated with the offsetParent of the element from the x-coordinate of the left border edge of the first box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors.

The offsetWidth attribute must return the result of running these steps:

  1. If the element does not have any associated box return zero and terminate this algorithm.

  2. Return the unscaled width of the axis-aligned bounding box of the border boxes of all fragments generated by the element’s principal box, ignoring any transforms that apply to the element and its ancestors.

    If the element’s principal box is an inline-level box which was "split" by a block-level descendant, also include fragments generated by the block-level descendants, unless they are zero width or height.

The offsetHeight attribute must return the result of running these steps:

  1. If the element does not have any associated box return zero and terminate this algorithm.

  2. Return the unscaled height of the axis-aligned bounding box of the border boxes of all fragments generated by the element’s principal box, ignoring any transforms that apply to the element and its ancestors.

    If the element’s principal box is an inline-level box which was "split" by a block-level descendant, also include fragments generated by the block-level descendants, unless they are zero width or height.

8. Extensions to the HTMLImageElement Interface

partial interface HTMLImageElement {
  readonly attribute long x;
  readonly attribute long y;
};

The x attribute, on getting, must return the scaled x-coordinate of the left border edge of the first box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors, or zero if there is no box.

The y attribute, on getting, must return the scaled y-coordinate of the top border edge of the first box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors, or zero if there is no box.

9. Extensions to the Range Interface

partial interface Range {
  DOMRectList getClientRects();
  [NewObject] DOMRect getBoundingClientRect();
};

The getClientRects() method, when invoked, must return an empty DOMRectList object if the range is not in the document and otherwise a DOMRectList object containing a list of DOMRect objects in content order that matches the following constraints:

Note: The DOMRect objects returned by getClientRects() are not live.

The getBoundingClientRect() method, when invoked, must return the result of the following algorithm:

  1. Let list be the result of invoking getClientRects() on the same range this method was invoked on.

  2. If list is empty return a DOMRect object whose x, y, width and height members are zero.

  3. If all rectangles in list have zero width or height, return the first rectangle in list.

  4. Otherwise, return a DOMRect object describing the smallest rectangle that includes all of the rectangles in list of which the height or width is not zero.

Note: The DOMRect object returned by getBoundingClientRect() is not live.

10. Extensions to the MouseEvent Interface

The object IDL fragment redefines some members. Can we resolve this somehow?

partial interface MouseEvent {
  readonly attribute double screenX;
  readonly attribute double screenY;
  readonly attribute double pageX;
  readonly attribute double pageY;
  readonly attribute double clientX;
  readonly attribute double clientY;
  readonly attribute double x;
  readonly attribute double y;
  readonly attribute double offsetX;
  readonly attribute double offsetY;
};

partial dictionary MouseEventInit {
  double screenX = 0.0;
  double screenY = 0.0;
  double clientX = 0.0;
  double clientY = 0.0;
};

The screenX attribute must return the x-coordinate of the position where the event occurred relative to the origin of the Web-exposed screen area.

The screenY attribute must return the y-coordinate of the position where the event occurred relative to the origin of the Web-exposed screen area.

The pageX attribute must follow these steps:

  1. If the event’s dispatch flag is set, return the horizontal coordinate of the position where the event occurred relative to the origin of the initial containing block and terminate these steps.

  2. Let offset be the value of the scrollX attribute of the event’s associated Window object, if there is one, or zero otherwise.

  3. Return the sum of offset and the value of the event’s clientX attribute.

The pageY attribute must follow these steps:

  1. If the event’s dispatch flag is set, return the vertical coordinate of the position where the event occurred relative to the origin of the initial containing block and terminate these steps.

  2. Let offset be the value of the scrollY attribute of the event’s associated Window object, if there is one, or zero otherwise.

  3. Return the sum of offset and the value of the event’s clientY attribute.

The clientX attribute must return the x-coordinate of the position where the event occurred relative to the origin of the viewport.

The clientY attribute must return the y-coordinate of the position where the event occurred relative to the origin of the viewport.

The x attribute must return the value of clientX.

The y attribute must return the value of clientY.

The offsetX attribute must follow these steps:

  1. If the event’s dispatch flag is set, return the x-coordinate of the position where the event occurred relative to the origin of the padding edge of the target node, ignoring the transforms that apply to the element and its ancestors, and terminate these steps.

  2. Return the value of the event’s pageX attribute.

The offsetY attribute must follow these steps:

  1. If the event’s dispatch flag is set, return the y-coordinate of the position where the event occurred relative to the origin of the padding edge of the target node, ignoring the transforms that apply to the element and its ancestors, and terminate these steps.

  2. Return the value of the event’s pageY attribute.

11. Geometry

11.1. The GeometryUtils Interface

enum CSSBoxType { "margin", "border", "padding", "content" };
dictionary BoxQuadOptions {
  CSSBoxType box = "border";
  GeometryNode relativeTo; // XXX default document (i.e. viewport)
};

dictionary ConvertCoordinateOptions {
  CSSBoxType fromBox = "border";
  CSSBoxType toBox = "border";
};

interface mixin GeometryUtils {
  sequence<DOMQuad> getBoxQuads(optional BoxQuadOptions options = {});
  DOMQuad convertQuadFromNode(DOMQuadInit quad, GeometryNode from, optional ConvertCoordinateOptions options = {});
  DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options = {});
  DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options = {}); // XXX z,w turns into 0
};

Text includes GeometryUtils; // like Range
Element includes GeometryUtils;
CSSPseudoElement includes GeometryUtils;
Document includes GeometryUtils;

typedef (Text or Element or CSSPseudoElement or Document) GeometryNode;

The getBoxQuads(options) method must run the following steps:

  1. DOM order

    p1 = top left even in RTL

    scale to 0 means divide by zero, return 0x0

    cross-frames not allowed, throw WrongDocumentError?

    points are flattened (3d transform), z=0. like getClientRect

    test block in inline

    pseudo-elements before/after are children of the element

    viewport boxes are all the same

The convertQuadFromNode(quad, from, options) method must run the following steps:

  1. ...

The convertRectFromNode(rect, from, options) method must run the following steps:

  1. ...

The convertPointFromNode(point, from, options) method must run the following steps:

  1. ...

12. VisualViewport

12.1. The VisualViewport Interface

[Exposed=Window]
interface VisualViewport : EventTarget {
  readonly attribute double offsetLeft;
  readonly attribute double offsetTop;

  readonly attribute double pageLeft;
  readonly attribute double pageTop;

  readonly attribute double width;
  readonly attribute double height;

  readonly attribute double scale;

  attribute EventHandler onresize;
  attribute EventHandler onscroll;
  attribute EventHandler onscrollend;
};

The offsetLeft attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0.

  2. Otherwise, return the offset of the left edge of the visual viewport from the left edge of the layout viewport.

The offsetTop attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0.

  2. Otherwise, return the offset of the top edge of the visual viewport from the top edge of the layout viewport.

The pageLeft attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0.

  2. Otherwise, return the offset of the left edge of the visual viewport from the left edge of the initial containing block of the layout viewport’s document.

The pageTop attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0.

  2. Otherwise, return the offset of the top edge of the visual viewport from the top edge of the initial containing block of the layout viewport’s document.

The width attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0.

  2. Otherwise, return the width of the visual viewport excluding the width of any rendered vertical classic scrollbar that is fixed to the visual viewport.

Note: Since this value is returned in CSS pixels, the value will decrease in magnitude if either page zoom or the scale factor is increased.

Note: A scrollbar that is fixed to the visual viewport is one that does not change size or location as the visual viewport is zoomed and panned. Because this value is in CSS pixels, when excluding the scrollbar width the UA must account for how large the scrollbar is as measured in CSS pixels. That is, the amount excluded decreases when zooming in and increases when zooming out.

The height attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0.

  2. Otherwise, return the height of the visual viewport excluding the height of any rendered horizontal classic scrollbar that is fixed to the visual viewport.

The scale attribute must run these steps:

  1. If the visual viewport’s associated document is not fully active, return 0 and abort these steps.

  2. If there is no output device, return 1 and abort these steps.

  3. Otherwise, return the visual viewport’s scale factor.

onresize is the event handler IDL attribute for the resize event.

onscroll is the event handler IDL attribute for the scroll event.

onscrollend is the event handler IDL attribute for the scrollend event.

13. Events

13.1. Resizing viewports

This section integrates with the event loop defined in HTML. [HTML]

When asked to run the resize steps for a Document doc, run these steps:

  1. If doc’s viewport has had its width or height changed (e.g. as a result of the user resizing the browser window, or changing page zoom, or an iframe element’s dimensions are changed) since the last time these steps were run, fire an event named resize at the Window object associated with doc.

  2. If the VisualViewport associated with doc has had its scale, width, or height properties changed since the last time these steps were run, fire an event named resize at the VisualViewport.

13.2. Scrolling

This section integrates with the event loop defined in HTML. [HTML]

Each Document has an associated list of pending scroll event targets, initially empty.

Each Document has an associated list of pending scrollend event targets, initially empty.

Whenever a viewport gets scrolled (whether in response to user interaction or by an API), the user agent must run these steps:

  1. Let doc be the viewport’s associated Document.

  2. If doc is a snap container, run the steps to update scrollsnapchanging targets for doc with doc’s eventual snap target in the block axis as newBlockTarget and doc’s eventual snap target in the inline axis as newInlineTarget.

  3. If doc is already in doc’s pending scroll event targets, abort these steps.

  4. Append doc to doc’s pending scroll event targets.

Whenever an element gets scrolled (whether in response to user interaction or by an API), the user agent must run these steps:

  1. Let doc be the element’s node document.

  2. If the element is a snap container, run the steps to update scrollsnapchanging targets for the element with the element’s eventual snap target in the block axis as newBlockTarget and the element’s eventual snap target in the inline axis as newInlineTarget.

  3. If the element is already in doc’s pending scroll event targets, abort these steps.

  4. Append the element to doc’s pending scroll event targets.

Whenever a visual viewport gets scrolled (whether in response to user interaction or by an API), the user agent must run these steps:

  1. Let vv be the VisualViewport object that was scrolled.

  2. Let doc be vv’s associated document.

  3. If vv is already in doc’s pending scroll event targets, abort these steps.

  4. Append vv to doc’s pending scroll event targets.

When asked to run the scroll steps for a Document doc, run these steps:

  1. Run the steps to dispatch pending scrollsnapchanging events for doc.

  2. For each item target in doc’s pending scroll event targets, in the order they were added to the list, run these substeps:

    1. If target is a Document, fire an event named scroll that bubbles at target.

    2. Otherwise, fire an event named scroll at target.

  3. Empty doc’s pending scroll event targets.

  4. Run the steps to dispatch pending scrollsnapchange events for doc.

Whenever scrolling is completed, the user agent must run these steps:

In what order are scrollend events dispatched? Ordered based on scroll start or scroll completion?

  1. For each scrolling box box that was scrolled:

    1. If box belongs to a viewport, let doc be the viewport’s associated Document and target be the viewport. If box belongs to a VisualViewport, let doc be the VisualViewport's associated document and target be the VisualViewport. Otherwise, box belongs to an element and let doc be the element’s node document and target be the element.

    2. If box belongs to a snap container, snapcontainer, run the update scrollsnapchange targets steps for snapcontainer.

    3. If target is already in doc’s pending scrollend event targets, abort these steps.

    4. Append target to doc’s pending scrollend event targets.

  2. Run the steps to dispatch pending scrollsnapchange targets for doc.

  3. For each item target in doc’s pending scrollend event targets, in the order they were added to the list, run these substeps:

    1. If target is a Document, fire an event named scrollend that bubbles at target.

    2. Otherwise, fire an event named scrollend at target.

  4. Empty doc’s pending scrollend event targets.

13.3. Event summary

This section is non-normative.

Event Interface Interesting targets Description
resize Event Window, VisualViewport Fired at the Window when the viewport is resized. Fired at VisualViewport when the visual viewport is resized or the layout viewport is scaled.
scroll Event VisualViewport, Document, elements Fired at the VisualViewport, Document or element when the VisualViewport, viewport, or element is scrolled, respectively.
scrollend Event Document, elements, VisualViewport Fired at the VisualViewport, Document, or element when a scroll is completed: the VisualViewport, viewport, or element has been scrolled, the scroll sequence has ended and any scroll offset changes have been applied.

14. Post-Layout State Snapshotting

Some CSS features use post-layout state, like scroll position, as input to the next style and layout update.

When asked to run snapshot post-layout state steps for a Document doc, run these steps:

  1. For each CSS feature that needs to snapshot post-layout state, take a snapshot of the relevant state in doc.

The state that is snapshot is defined in other specifications. These steps must not invalidate doc or any other Documents in such a way that other post-layout snapshotting steps can observe that such snapshotting happened. It follows that the order of which such snapshotting takes place must not matter.

15. Security and Privacy Considerations

The Screen interface exposes information about the user’s display configuration, which maybe be used as input to fingerprinting algorithms. User agents may choose to hide or quantize information about the screen size or configuration, in order to protect the user’s privacy.

MouseEvent contains information about the screen-relative coordinates of the event. User agents may set these properties to values that obscure the actual screen-relative location of the event, in order to protect the user’s privacy.

16. Changes

This section documents some of the changes between publications of this specification. This section is not exhaustive. Bug fixes and editorial changes are generally not listed.

Changes From 07 July 2022

Changes From 22 June 2022

Changes From 19 October 2020

Changes From 31 January 2020

Changes From 17 December 2013 To 31 January 2020

Changes From 4 August 2011 To 17 December 2013

17. Acknowledgements

The editors would like to thank Alan Stearns, Alexey Feldgendler, Antonio Gomes, Björn Höhrmann, Boris Zbarsky, Chris Rebert, Corey Farwell, Dan Bates, David Vest, Elliott Sprehn, Garrett Smith, Henrik Andersson, Hallvord R. M. Steen, Kang-Hao Lu, Koji Ishii, Leif Arne Storset, Luiz Agostini, Maciej Stachowiak, Michael Dyck, Mike Wilson, Morten Stenshorne, Olli Pettay, Pavel Curtis, Peter-Paul Koch, Rachel Kmetz, Rick Byers, Robert O’Callahan, Sam Weinig, Scott Johnson, Sebastian Zartner, Stewart Brodie, Sylvain Galineau, Tab Atkins, Tarquin Wilton-Jones, Thomas Moore, Thomas Shinnick, and Xiaomei Ji for their contributions to this document.

Special thanks to the Microsoft employees who first implemented many of the features specified in this draft, which were first widely deployed by the Windows Internet Explorer browser.

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.

Tests

Tests relating to the content of this specification may be documented in “Tests” blocks like this one. Any such block is non-normative.


Conformance classes

Conformance to this specification is defined for three conformance classes:

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

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

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

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

Partial implementations

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

Implementations of Unstable and Proprietary Features

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

Non-experimental implementations

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

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

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the [email protected] mailing list.

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. URL: https://drafts.csswg.org/css-align/
[CSS-BACKGROUNDS-3]
Elika Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. URL: https://drafts.csswg.org/css-backgrounds/
[CSS-BOX-4]
Elika Etemad. CSS Box Model Module Level 4. URL: https://drafts.csswg.org/css-box-4/
[CSS-BREAK-4]
Rossen Atanassov; Elika Etemad. CSS Fragmentation Module Level 4. URL: https://drafts.csswg.org/css-break-4/
[CSS-COLOR-4]
Chris Lilley; Tab Atkins Jr.; Lea Verou. CSS Color Module Level 4. URL: https://drafts.csswg.org/css-color-4/
[CSS-CONTAIN-2]
Tab Atkins Jr.; Florian Rivoal; Vladimir Levin. CSS Containment Module Level 2. URL: https://drafts.csswg.org/css-contain-2/
[CSS-DEVICE-ADAPT]
Florian Rivoal; Emilio Cobos Álvarez. CSS Viewport Module Level 1. URL: https://drafts.csswg.org/css-viewport/
[CSS-DISPLAY-4]
CSS Display Module Level 4. Editor's Draft. URL: https://drafts.csswg.org/css-display-4/
[CSS-OVERFLOW-3]
Elika Etemad; Florian Rivoal. CSS Overflow Module Level 3. URL: https://drafts.csswg.org/css-overflow-3/
[CSS-POSITION-3]
Elika Etemad; Tab Atkins Jr.. CSS Positioned Layout Module Level 3. URL: https://drafts.csswg.org/css-position-3/
[CSS-PSEUDO-4]
Daniel Glazman; Elika Etemad; Alan Stearns. CSS Pseudo-Elements Module Level 4. URL: https://drafts.csswg.org/css-pseudo-4/
[CSS-SCOPING-1]
Tab Atkins Jr.; Elika Etemad. CSS Scoping Module Level 1. URL: https://drafts.csswg.org/css-scoping/
[CSS-SCROLL-SNAP-1]
Matt Rakow; et al. CSS Scroll Snap Module Level 1. URL: https://drafts.csswg.org/css-scroll-snap-1/
[CSS-SCROLL-SNAP-2]
Elika Etemad; Tab Atkins Jr.; Adam Argyle. CSS Scroll Snap Module Level 2. URL: https://drafts.csswg.org/css-scroll-snap-2/
[CSS-TEXT-3]
Elika Etemad; Koji Ishii; Florian Rivoal. CSS Text Module Level 3. URL: https://drafts.csswg.org/css-text-3/
[CSS-TEXT-4]
Elika Etemad; et al. CSS Text Module Level 4. URL: https://drafts.csswg.org/css-text-4/
[CSS-TRANSFORMS-1]
Simon Fraser; et al. CSS Transforms Module Level 1. URL: https://drafts.csswg.org/css-transforms/
[CSS-VALUES]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. URL: https://drafts.csswg.org/css-values-3/
[CSS-VALUES-4]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. URL: https://drafts.csswg.org/css-values-4/
[CSS-WRITING-MODES-4]
Elika Etemad; Koji Ishii. CSS Writing Modes Level 4. URL: https://drafts.csswg.org/css-writing-modes-4/
[CSSOM]
Daniel Glazman; Emilio Cobos Álvarez. CSS Object Model (CSSOM). URL: https://drafts.csswg.org/cssom/
[DOM]
Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
[GEOMETRY-1]
Simon Pieters; Chris Harrelson. Geometry Interfaces Module Level 1. URL: https://drafts.fxtf.org/geometry/
[HTML]
Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[MEDIAQUERIES-5]
Dean Jackson; et al. Media Queries Level 5. URL: https://drafts.csswg.org/mediaqueries-5/
[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
[SELECTORS-4]
Elika Etemad; Tab Atkins Jr.. Selectors Level 4. URL: https://drafts.csswg.org/selectors/
[SVG11]
Erik Dahlström; et al. Scalable Vector Graphics (SVG) 1.1 (Second Edition). 16 August 2011. REC. URL: https://www.w3.org/TR/SVG11/
[SVG2]
Amelia Bellamy-Royds; et al. Scalable Vector Graphics (SVG) 2. URL: https://svgwg.org/svg2-draft/
[UIEVENTS]
Gary Kacmarcik; Travis Leithead. UI Events. URL: https://w3c.github.io/uievents/
[WEBIDL]
Edgar Chen; Timothy Gu. Web IDL Standard. Living Standard. URL: https://webidl.spec.whatwg.org/

Informative References

[CSS-UI-4]
Florian Rivoal. CSS Basic User Interface Module Level 4. URL: https://drafts.csswg.org/css-ui-4/
[CSSOM-VIEW-1]
Simon Pieters. CSSOM View Module. URL: https://drafts.csswg.org/cssom-view/

IDL Index

enum ScrollBehavior { "auto", "instant", "smooth" };

dictionary ScrollOptions {
    ScrollBehavior behavior = "auto";
};
dictionary ScrollToOptions : ScrollOptions {
    unrestricted double left;
    unrestricted double top;
};

partial interface Window {
    [NewObject] MediaQueryList matchMedia(CSSOMString query);
    [SameObject, Replaceable] readonly attribute Screen screen;
    [SameObject, Replaceable] readonly attribute VisualViewport? visualViewport;

    // browsing context
    undefined moveTo(long x, long y);
    undefined moveBy(long x, long y);
    undefined resizeTo(long width, long height);
    undefined resizeBy(long x, long y);

    // viewport
    [Replaceable] readonly attribute long innerWidth;
    [Replaceable] readonly attribute long innerHeight;

    // viewport scrolling
    [Replaceable] readonly attribute double scrollX;
    [Replaceable] readonly attribute double pageXOffset;
    [Replaceable] readonly attribute double scrollY;
    [Replaceable] readonly attribute double pageYOffset;
    undefined scroll(optional ScrollToOptions options = {});
    undefined scroll(unrestricted double x, unrestricted double y);
    undefined scrollTo(optional ScrollToOptions options = {});
    undefined scrollTo(unrestricted double x, unrestricted double y);
    undefined scrollBy(optional ScrollToOptions options = {});
    undefined scrollBy(unrestricted double x, unrestricted double y);

    // client
    [Replaceable] readonly attribute long screenX;
    [Replaceable] readonly attribute long screenLeft;
    [Replaceable] readonly attribute long screenY;
    [Replaceable] readonly attribute long screenTop;
    [Replaceable] readonly attribute long outerWidth;
    [Replaceable] readonly attribute long outerHeight;
    [Replaceable] readonly attribute double devicePixelRatio;
};

[Exposed=Window]
interface MediaQueryList : EventTarget {
  readonly attribute CSSOMString media;
  readonly attribute boolean matches;
  undefined addListener(EventListener? callback);
  undefined removeListener(EventListener? callback);
           attribute EventHandler onchange;
};

[Exposed=Window]
interface MediaQueryListEvent : Event {
  constructor(CSSOMString type, optional MediaQueryListEventInit eventInitDict = {});
  readonly attribute CSSOMString media;
  readonly attribute boolean matches;
};

dictionary MediaQueryListEventInit : EventInit {
  CSSOMString media = "";
  boolean matches = false;
};

[Exposed=Window]
interface Screen {
  readonly attribute long availWidth;
  readonly attribute long availHeight;
  readonly attribute long width;
  readonly attribute long height;
  readonly attribute unsigned long colorDepth;
  readonly attribute unsigned long pixelDepth;
};

partial interface Document {
  Element? elementFromPoint(double x, double y);
  sequence<Element> elementsFromPoint(double x, double y);
  CaretPosition? caretPositionFromPoint(double x, double y, optional CaretPositionFromPointOptions options = {});
  readonly attribute Element? scrollingElement;
};

dictionary CaretPositionFromPointOptions {
  sequence<ShadowRoot> shadowRoots = [];
};

[Exposed=Window]
interface CaretPosition {
  readonly attribute Node offsetNode;
  readonly attribute unsigned long offset;
  [NewObject] DOMRect? getClientRect();
};

enum ScrollLogicalPosition { "start", "center", "end", "nearest" };
dictionary ScrollIntoViewOptions : ScrollOptions {
  ScrollLogicalPosition block = "start";
  ScrollLogicalPosition inline = "nearest";
};

dictionary CheckVisibilityOptions {
    boolean checkOpacity = false;
    boolean checkVisibilityCSS = false;
    boolean contentVisibilityAuto = false;
    boolean opacityProperty = false;
    boolean visibilityProperty = false;
};

partial interface Element {
  DOMRectList getClientRects();
  [NewObject] DOMRect getBoundingClientRect();

  boolean checkVisibility(optional CheckVisibilityOptions options = {});

  undefined scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = {});
  undefined scroll(optional ScrollToOptions options = {});
  undefined scroll(unrestricted double x, unrestricted double y);
  undefined scrollTo(optional ScrollToOptions options = {});
  undefined scrollTo(unrestricted double x, unrestricted double y);
  undefined scrollBy(optional ScrollToOptions options = {});
  undefined scrollBy(unrestricted double x, unrestricted double y);
  attribute unrestricted double scrollTop;
  attribute unrestricted double scrollLeft;
  readonly attribute long scrollWidth;
  readonly attribute long scrollHeight;
  readonly attribute long clientTop;
  readonly attribute long clientLeft;
  readonly attribute long clientWidth;
  readonly attribute long clientHeight;
  readonly attribute double currentCSSZoom;
};

partial interface HTMLElement {
  readonly attribute Element? offsetParent;
  readonly attribute long offsetTop;
  readonly attribute long offsetLeft;
  readonly attribute long offsetWidth;
  readonly attribute long offsetHeight;
};

partial interface HTMLImageElement {
  readonly attribute long x;
  readonly attribute long y;
};

partial interface Range {
  DOMRectList getClientRects();
  [NewObject] DOMRect getBoundingClientRect();
};

partial interface MouseEvent {
  readonly attribute double screenX;
  readonly attribute double screenY;
  readonly attribute double pageX;
  readonly attribute double pageY;
  readonly attribute double clientX;
  readonly attribute double clientY;
  readonly attribute double x;
  readonly attribute double y;
  readonly attribute double offsetX;
  readonly attribute double offsetY;
};

partial dictionary MouseEventInit {
  double screenX = 0.0;
  double screenY = 0.0;
  double clientX = 0.0;
  double clientY = 0.0;
};

enum CSSBoxType { "margin", "border", "padding", "content" };
dictionary BoxQuadOptions {
  CSSBoxType box = "border";
  GeometryNode relativeTo; // XXX default document (i.e. viewport)
};

dictionary ConvertCoordinateOptions {
  CSSBoxType fromBox = "border";
  CSSBoxType toBox = "border";
};

interface mixin GeometryUtils {
  sequence<DOMQuad> getBoxQuads(optional BoxQuadOptions options = {});
  DOMQuad convertQuadFromNode(DOMQuadInit quad, GeometryNode from, optional ConvertCoordinateOptions options = {});
  DOMQuad convertRectFromNode(DOMRectReadOnly rect, GeometryNode from, optional ConvertCoordinateOptions options = {});
  DOMPoint convertPointFromNode(DOMPointInit point, GeometryNode from, optional ConvertCoordinateOptions options = {}); // XXX z,w turns into 0
};

Text includes GeometryUtils; // like Range
Element includes GeometryUtils;
CSSPseudoElement includes GeometryUtils;
Document includes GeometryUtils;

typedef (Text or Element or CSSPseudoElement or Document) GeometryNode;

[Exposed=Window]
interface VisualViewport : EventTarget {
  readonly attribute double offsetLeft;
  readonly attribute double offsetTop;

  readonly attribute double pageLeft;
  readonly attribute double pageTop;

  readonly attribute double width;
  readonly attribute double height;

  readonly attribute double scale;

  attribute EventHandler onresize;
  attribute EventHandler onscroll;
  attribute EventHandler onscrollend;
};

Issues Index

User agents do not agree whether this uses the (coordinated) viewport perform a scroll or the scrolling box perform a scroll on the layout viewport’s scrolling box.
The object IDL fragment redefines some members. Can we resolve this somehow?
DOM order

p1 = top left even in RTL

scale to 0 means divide by zero, return 0x0

cross-frames not allowed, throw WrongDocumentError?

points are flattened (3d transform), z=0. like getClientRect

test block in inline

pseudo-elements before/after are children of the element

viewport boxes are all the same

...
...
...
In what order are scrollend events dispatched? Ordered based on scroll start or scroll completion?
MDN

CaretPosition

In only one current engine.

Firefox20+SafariNoneChromeNone
Opera?EdgeNone
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Document/caretPositionFromPoint

In only one current engine.

Firefox20+SafariNoneChromeNone
Opera?EdgeNone
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Document/elementFromPoint

In all current engines.

Firefox3+Safari4+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

Document/elementsFromPoint

In all current engines.

Firefox46+Safari11.1+Chrome43+
Opera30+Edge79+
Edge (Legacy)NoneIENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile30+
MDN

Document/scroll_event

In all current engines.

Firefox6+Safari2+Chrome1+
Opera11.6+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12+

Element/scroll_event

In all current engines.

Firefox6+Safari1.3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+

VisualViewport/scroll_event

In all current engines.

Firefox91+Safari13+Chrome62+
Opera?Edge79+
Edge (Legacy)NoneIENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet8.0+Opera Mobile?
MDN

Document/scrollend_event

Firefox109+SafariNoneChrome114+
Opera?Edge114+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?

Element/scrollend_event

Firefox109+SafariNoneChrome114+
Opera?Edge114+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Document/scrollingElement

In all current engines.

Firefox48+Safari9+Chrome44+
Opera?Edge79+
Edge (Legacy)12+IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Document

In all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile10.1+
MDN

Element/clientHeight

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/clientLeft

In all current engines.

Firefox3+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/clientTop

In all current engines.

Firefox3+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/clientWidth

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/getBoundingClientRect

In all current engines.

Firefox3+Safari4+Chrome2+
Opera9.5+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari3.2+Chrome for Android?Android WebView2+Samsung Internet?Opera Mobile10.1+
MDN

Element/getClientRects

In all current engines.

Firefox3+Safari4+Chrome2+
Opera9.5+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView2+Samsung Internet?Opera Mobile10.1+
MDN

Element/scroll

In all current engines.

Firefox36+Safari10.1+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Element/scrollBy

In all current engines.

Firefox36+Safari10.1+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Element/scrollHeight

In all current engines.

Firefox21+Safari1+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/scrollIntoView

In all current engines.

Firefox1+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)NoneIENone
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Element/scrollLeft

In all current engines.

Firefox1+Safari1+Chrome86+
Opera8+Edge86+
Edge (Legacy)NoneIE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/scrollTo

In all current engines.

Firefox36+Safari10.1+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Element/scrollTop

In all current engines.

Firefox1+Safari1+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Element/scrollWidth

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Element

In all current engines.

Firefox1+Safari1+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile10.1+
MDN

HTMLElement/offsetHeight

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5.5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

HTMLElement/offsetLeft

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5.5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

HTMLElement/offsetParent

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5.5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

HTMLElement/offsetTop

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5.5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

HTMLElement/offsetWidth

In all current engines.

Firefox1+Safari3+Chrome1+
Opera8+Edge79+
Edge (Legacy)12+IE5.5+
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

HTMLImageElement/x

In all current engines.

Firefox14+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IENone
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

HTMLImageElement/y

In all current engines.

Firefox14+Safari3+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IENone
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

MediaQueryList/change_event

In all current engines.

Firefox55+Safari14+Chrome39+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

MediaQueryList/matches

In all current engines.

Firefox6+Safari5.1+Chrome9+
Opera12.1+Edge79+
Edge (Legacy)12+IE10+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MediaQueryList/media

In all current engines.

Firefox6+Safari5.1+Chrome9+
Opera12.1+Edge79+
Edge (Legacy)12+IE10+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MediaQueryList

In all current engines.

Firefox6+Safari5.1+Chrome9+
Opera12.1+Edge79+
Edge (Legacy)12+IE10+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+

MediaQueryListEvent

In all current engines.

Firefox55+Safari14+Chrome39+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

MediaQueryListEvent/MediaQueryListEvent

In all current engines.

Firefox55+Safari14+Chrome39+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

MediaQueryListEvent/matches

In all current engines.

Firefox55+Safari14+Chrome39+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

MediaQueryListEvent/media

In all current engines.

Firefox55+Safari14+Chrome39+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

MouseEvent/offsetX

In all current engines.

Firefox39+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android43+iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MouseEvent/offsetY

In all current engines.

Firefox39+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android43+iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MouseEvent/pageX

In all current engines.

Firefox1.5+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MouseEvent/pageY

In all current engines.

Firefox1.5+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MouseEvent/x

In all current engines.

Firefox53+Safari3.1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MouseEvent/y

In all current engines.

Firefox53+Safari3.1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

MouseEvent

In all current engines.

Firefox1+Safari1+Chrome1+
Opera10.6+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile11+
MDN

Range/getBoundingClientRect

In all current engines.

Firefox4+Safari5+Chrome4+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari4+Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

Range/getClientRects

In all current engines.

Firefox4+Safari5+Chrome4+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari4+Chrome for Android?Android WebView37+Samsung Internet?Opera Mobile12.1+
MDN

Range

In all current engines.

Firefox1+Safari1+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Screen/availHeight

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Screen/availWidth

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Screen/colorDepth

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet1.0+Opera Mobile12.1+
MDN

Screen/height

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Screen/pixelDepth

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet1.0+Opera Mobile12.1+
MDN

Screen/width

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Screen

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

VisualViewport/height

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport/offsetLeft

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport/offsetTop

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport/pageLeft

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport/pageTop

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport/resize_event

In all current engines.

Firefox91+Safari13+Chrome62+
Opera?Edge79+
Edge (Legacy)NoneIENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet8.0+Opera Mobile?
MDN

VisualViewport/scale

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport/width

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

VisualViewport

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
MDN

Window/devicePixelRatio

In all current engines.

Firefox18+Safari3+Chrome1+
Opera11.1+Edge79+
Edge (Legacy)12+IE11
Firefox for Android?iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile11.1+
MDN

Window/innerHeight

In all current engines.

Firefox1+Safari3+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android4+iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/innerWidth

In all current engines.

Firefox1+Safari3+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android4+iOS Safari1+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/matchMedia

In all current engines.

Firefox6+Safari5.1+Chrome9+
Opera12.1+Edge79+
Edge (Legacy)12+IE10+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView3+Samsung Internet?Opera Mobile12.1+
MDN

Window/moveBy

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/moveTo

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/open

In all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/outerHeight

In all current engines.

Firefox1+Safari3+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari3+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/outerWidth

In all current engines.

Firefox1+Safari3+Chrome1+
Opera9+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari3+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/pageXOffset

In all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/pageYOffset

In all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/resize_event

In all current engines.

Firefox1+Safari1.1+Chrome1+
Opera7+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView1+Samsung Internet?Opera Mobile10.1+
MDN

Window/resizeBy

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android4+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/resizeTo

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android4+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/screen

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/screenLeft

In all current engines.

Firefox64+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/screenTop

In all current engines.

Firefox64+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE5+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/screenX

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/screenY

In all current engines.

Firefox1+Safari1+Chrome1+
Opera12.1+Edge79+
Edge (Legacy)12+IE9+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile12.1+
MDN

Window/scroll

In all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/scrollBy

In all current engines.

Firefox1+Safari1+Chrome1+
Opera3+Edge79+
Edge (Legacy)12+IE11
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/scrollTo

In all current engines.

Firefox1+Safari1+Chrome1+
Opera4+Edge79+
Edge (Legacy)12+IE4+
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/scrollX

In all current engines.

Firefox1+Safari1+Chrome1+
Opera9.6+Edge79+
Edge (Legacy)12+IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/scrollY

In all current engines.

Firefox1+Safari1+Chrome1+
Opera9.6+Edge79+
Edge (Legacy)12+IENone
Firefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile10.1+
MDN

Window/visualViewport

In all current engines.

Firefox91+Safari13+Chrome61+
Opera?Edge79+
Edge (Legacy)?IENone
Firefox for Android68+iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
CanIUse

Support:Android Browser3+Baidu Browser13.52+Blackberry Browser10+Chrome9+Chrome for Android130+Edge12+Firefox6+Firefox for Android130+IE10+IE Mobile10+KaiOS Browser2.5+Opera12.1+Opera MiniAllOpera Mobile12.1+QQ Browser14.9+Safari5.1+Safari on iOS5.0+Samsung Internet4+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10

CanIUse

Support:Android Browser2.1+Baidu Browser13.52+Blackberry Browser7+Chrome4+Chrome for Android130+Edge12+Firefox18+Firefox for Android130+IE11+IE Mobile11+KaiOS Browser2.5+Opera11.6+Opera MiniAllOpera Mobile12+QQ Browser14.9+Safari3.1+Safari on iOS3.2+Samsung Internet4+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10

CanIUse

Support:Android Browser2.3+Baidu Browser13.52+Blackberry Browser7+Chrome15+Chrome for Android130+Edge12+Firefox3+Firefox for Android130+IE6+IE Mobile10+KaiOS Browser2.5+Opera11+Opera MiniAllOpera Mobile12+QQ Browser14.9+Safari5+Safari on iOS4.0+Samsung Internet4+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10

CanIUse

Support:Android Browser130+Baidu Browser13.52+Blackberry BrowserNoneChrome44+Chrome for Android130+Edge14+Firefox48+Firefox for Android130+IENoneIE MobileNoneKaiOS Browser2.5+Opera31+Opera MiniNoneOpera Mobile80+QQ Browser14.9+Safari9+Safari on iOS9.0+Samsung Internet4+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10

CanIUse

Support:Android Browser130+Baidu Browser13.52+Blackberry BrowserNoneChrome61+Chrome for Android130+Edge79+Firefox36+Firefox for Android130+IENoneIE MobileNoneKaiOS Browser2.5+Opera48+Opera MiniNoneOpera Mobile80+QQ Browser14.9+Safari14+Safari on iOS14.5+Samsung Internet8.2+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10

CanIUse

Support:Android Browser2.3+Baidu Browser13.52+Blackberry Browser7+Chrome4+Chrome for Android130+Edge12+Firefox12+Firefox for Android130+IE9+IE Mobile10+KaiOS Browser2.5+Opera10.6+Opera MiniAllOpera Mobile11+QQ Browser14.9+Safari4+Safari on iOS4.0+Samsung Internet4+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10

CanIUse

Support:Android Browser130+Baidu Browser13.52+Blackberry Browser (limited)7+Chrome61+Chrome for Android130+Edge79+Firefox36+Firefox for Android130+IE (limited)8+IE Mobile (limited)10+KaiOS Browser2.5+Opera48+Opera MiniNoneOpera Mobile80+QQ Browser14.9+Safari16.0+Safari on iOS16.0+Samsung Internet8.2+UC Browser for Android15.5+

Source: caniuse.com as of 2024-11-10