The :fullscreen pseudo-class styles elements when they occupy the entire screen through the Fullscreen API or native media controls.
01
Fullscreen
Full viewport.
02
API
requestFullscreen.
03
Video
Media players.
04
vw / vh
Flexible units.
05
::backdrop
Dim background.
06
Immersive
Rich experiences.
Fundamentals
Introduction
The :fullscreen selector in CSS is used to style elements when they are in fullscreen mode.
This pseudo-class becomes active when an element is displayed using the Fullscreen API, typically triggered by the user clicking a button or through JavaScript.
It is a useful tool for enhancing the visual experience when elements are displayed fullscreen — such as videos, image galleries, presentations, or interactive sections of a webpage.
Definition and Usage
Append :fullscreen to a selector with no space before the colon: :fullscreen, video:fullscreen, or div:fullscreen. Styles apply only while the element is in fullscreen and revert when the user exits (usually by pressing Esc).
💡
Beginner Tip
CSS cannot enter fullscreen by itself. You need JavaScript element.requestFullscreen() or the browser’s native video fullscreen button. The :fullscreen selector only styles the element once it is already fullscreen.
Foundation
📝 Syntax
The syntax for the :fullscreen pseudo-class is:
syntax.css
:fullscreen{/* CSS properties */}
Basic Example
fullscreen-basic.css
/* Default styling */#player{width:300px;height:200px;background:#93c5fd;}/* When in fullscreen mode */:fullscreen{width:100vw;height:100vh;background:#1e3a8a;color:#fff;display:flex;align-items:center;justify-content:center;}
When the user clicks the button, JavaScript calls requestFullscreen(). The browser promotes the div to fullscreen, and the :fullscreen rules expand it to fill the viewport with a new color scheme.
Example 2 — Video fullscreen styling
Target a video element specifically with video:fullscreen for media players.
Video fills screen with black letterbox background (object-fit: contain).
How It Works
Videos can enter fullscreen via native browser controls. video:fullscreen ensures the video scales properly with object-fit: contain and a black background for letterboxing.
📄 Layout & Backdrop
Center content and style the backdrop layer behind fullscreen elements.
Example 3 — Centered fullscreen content with flexbox
Use flexbox inside :fullscreen to center text, images, or controls on large screens.
Gallery content on white panel over dark backdrop.
How It Works
The ::backdrop pseudo-element covers everything behind the fullscreen element. A semi-transparent dark backdrop creates a modal-like, focused viewing experience.
Tips
💬 Usage Tips
Combine :fullscreen with specific elements (video:fullscreen, div:fullscreen) for precise targeting.
Use flexible units like vw and vh so designs adapt to any screen size in fullscreen.
Provide a visible button to enter and exit fullscreen — do not rely on hidden gestures alone.
Listen for fullscreenchange to toggle icons (expand/compress) in your UI.
Test on mobile — some browsers handle fullscreen differently on iOS Safari.
Watch Out
⚠️ Common Pitfalls
Requires Fullscreen API — :fullscreen only works after requestFullscreen() or native media controls — CSS alone cannot trigger it.
Element limitations — Not all elements support fullscreen in every browser (e.g., some iframe restrictions).
Vendor prefixes — Older browsers used :-webkit-full-screen and :-moz-full-screen; modern browsers support standard :fullscreen.
Forgetting exit path — Always let users exit with Esc or an explicit exit button.
Fixed positioning confusion — position: fixed is not the same as fullscreen; only the Fullscreen API triggers :fullscreen.
🧠 How :fullscreen Works
1
User triggers fullscreen
Click a button or use native video controls. JavaScript calls requestFullscreen().
Trigger
2
Browser promotes element
The element expands to fill the screen. The browser fires a fullscreenchange event.
Promote
3
:fullscreen styles apply
CSS rules for :fullscreen and ::backdrop take effect.
Style
=
⛶
Immersive experience
Content fills the screen with your custom fullscreen design.
Compatibility
🖥 Browser Compatibility
The standard :fullscreen pseudo-class is supported in all modern browsers. Legacy browsers used vendor-prefixed variants.
✓ Baseline · Modern browsers
Fullscreen styling everywhere
:fullscreen works in Chrome, Firefox, Safari, Edge, and Opera. Use vendor prefixes only if you must support very old browsers.
96%Modern support
Google Chrome71+ · Standard :fullscreen
Full support
Mozilla Firefox64+ · Standard :fullscreen
Full support
Apple Safari16.4+ · Standard :fullscreen
Full support
Microsoft Edge79+ · Standard :fullscreen
Full support
Opera58+ · Standard :fullscreen
Full support
:fullscreen pseudo-class96% supported
Bottom line: Use standard :fullscreen for all current projects. Add :-webkit-full-screen only if you need legacy Safari support.
Wrap Up
🎉 Conclusion
The :fullscreen selector is a powerful way to adapt your design to fullscreen mode. By applying custom styles when elements enter fullscreen, you can create immersive user experiences for media-rich content like videos, games, galleries, and interactive websites.
Pair it with the Fullscreen API, flexible viewport units, and ::backdrop styling to deliver polished, professional fullscreen interfaces.
Use these points when building immersive fullscreen experiences.
5
Core concepts
⛶01
Fullscreen mode
Fills screen.
Purpose
JS02
Fullscreen API
JS required.
Trigger
vw03
Viewport units
100vw / 100vh.
Layout
::04
::backdrop
Dim background.
Polish
🌐05
96% support
Modern browsers.
Compat
❓ Frequently Asked Questions
The :fullscreen pseudo-class matches an element that is currently displayed in fullscreen mode — filling the entire screen — after being promoted via the Fullscreen API or native browser controls.
JavaScript calls element.requestFullscreen() (or vendor-prefixed variants). Users can also trigger fullscreen on videos through the browser's native video controls.
The CSS selector only applies when an element is in fullscreen. Entering fullscreen requires the Fullscreen API or native media controls — CSS alone cannot toggle fullscreen.
::backdrop is a pseudo-element that styles the layer behind a fullscreen element. Use it to dim or color the area outside the fullscreen content.
All modern browsers support the standard :fullscreen pseudo-class. Older browsers used vendor prefixes like :-webkit-full-screen and :-moz-full-screen.