Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

:xr-overlay — the active WebXR DOM overlay root

The :xr-overlay pseudo-class matches the DOM overlay element during an immersive WebXR session, allowing interface styling without manually toggling a class.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

:xr-overlay { /* declarations */ }

:xr-overlay matches the DOM overlay root throughout an immersive session using that overlay. It does not automatically match descendants; use a descendant selector, as in the example.

CSS alone cannot start XR. When requesting a session, the application must supply domOverlay.root and request dom-overlay. Matching does not require :fullscreen.

The user-agent stylesheet gives the overlay root a transparent background by default with background: transparent. The declaration is not marked !important, so author CSS can override it. The example does not start a session: text is gray normally and green while #overlay is used as the overlay. The specification remains a draft; implementation testing is required.

Examples

<!doctype html>
<meta charset="utf-8">
<title>:xr-overlay</title>
<style>
  #status { color: gray; }
  #overlay:xr-overlay #status { color: green; }
</style>
<div id="overlay">
  <p id="status">XR overlay status</p>
</div>

Result

Inactive: gray text. During an immersive session using #overlay as its DOM overlay root: green text.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources