Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

:fullscreen — an element in fullscreen state

The :fullscreen pseudo-class selects elements in fullscreen state. It lets you change their appearance during fullscreen presentation, but does not itself enter fullscreen mode.

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

Syntax

:fullscreen { /* declarations */ }
E:fullscreen { /* declarations */ }

:fullscreen is a pseudo-class without arguments. E:fullscreen selects an element of type E in fullscreen state; :fullscreen alone does not restrict the element type. The CSS rule responds to a state—it does not enable fullscreen.

The Fullscreen API defines matching through a set fullscreen flag. A Shadow DOM host can also match when retargeting the fullscreen target against that host yields the host itself. Several elements can therefore match :fullscreen simultaneously, whereas document.fullscreenElement identifies the topmost fullscreen element exposed in that context.

This is not a size test: filling the window using CSS does not set the fullscreen flag. Descendants do not automatically match just because they are inside a matching element. #panel:fullscreen styles the panel, while #panel:fullscreen p styles its paragraphs in that state.

The example calls requestFullscreen() after a click, handles rejection, and updates the result after fullscreenchange. Entering fullscreen requires permission to use the feature. The activation check passes if there is transient user activation or if a user-generated orientation change triggers the algorithm. The environment can reject the request. The expected result describes successful entry and exit, not guaranteed API availability.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>:fullscreen demo</title>
<style>
  #panel { padding: 24px; background: white; color: black; }
  #panel:fullscreen { background: navy; color: white; }
</style>
<section id="panel">
  <button id="toggle" type="button">Toggle fullscreen</button>
  <p id="status" role="status">fullscreen: false</p>
</section>
<script>
  const panel = document.querySelector('#panel');
  const status = document.querySelector('#status');
  document.querySelector('#toggle').addEventListener('click', async () => {
    try {
      if (document.fullscreenElement) {
        await document.exitFullscreen();
      } else {
        await panel.requestFullscreen();
      }
    } catch {
      status.textContent = 'Fullscreen request failed';
    }
  });
  document.addEventListener('fullscreenchange', () => {
    status.textContent = `fullscreen: ${panel.matches(':fullscreen')}`;
  });
</script>
</html>

Result

Initially: fullscreen: false
After successful entry: fullscreen: true; navy background and white text.
After exit: fullscreen: false; white background and black text.
If a request is rejected: Fullscreen request failed

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