CSS Reference ยท Media Queries and Features
The display-mode media feature
Reference for the CSS display-mode media feature: detect whether a web app runs in a browser tab, standalone, fullscreen or another installed mode, with examples.
The display-mode media feature reports how the page is currently being presented: in a normal browser tab, as an installed app in its own window, or in fullscreen. It is mainly useful for progressive web apps (PWAs), where an installed app has no address bar or back button of its own and may need its own navigation controls.
@media (display-mode: standalone) { .install-hint { display: none; } }
Try it
In a normal tab the preview matches browser. The label also changes if the page is fullscreen. Installed web apps would show standalone instead.
Syntax
@media (display-mode: browser) { /* ... */ } @media (display-mode: minimal-ui) { /* ... */ } @media (display-mode: standalone) { /* ... */ } @media (display-mode: fullscreen) { /* ... */ } @media (display-mode: picture-in-picture) { /* ... */ }
It is a discrete media feature.
Values
| Value | Description |
|---|---|
browser |
A normal browser tab or window. |
minimal-ui |
An app window with a small set of browser controls (such as back and reload). |
standalone |
An app window that looks like a native app, with no browser controls. |
fullscreen |
The page fills the whole screen. |
picture-in-picture |
The page is shown in a floating always-on-top window. |
window-controls-overlay |
An installed desktop app that draws into the title bar area. |
Usage notes
- Which mode applies is partly your choice. A web app manifest declares the preferred mode with its
displaymember; the browser picks the nearest mode it supports. - Fallback order. If the preferred mode is unavailable, browsers fall back in a fixed order, and the media feature reports what you actually got, not what you asked for.
- Typical uses. Hide an "Install app" banner when already installed, add your own back button in
standalone, and add padding for a custom title bar. - Fullscreen can be temporary. Pages that request fullscreen (for example a video player) enter and leave
fullscreenmode while the page is open. There is also the:fullscreenpseudo-class for styling the fullscreen element itself. - Not every value is everywhere. Values like
window-controls-overlayandpicture-in-pictureare newer and platform-specific, so treat them as enhancements. - JavaScript.
matchMedia("(display-mode: standalone)")gives the same information, and also lets you listen for changes.
Browser support
The common values browser, standalone, minimal-ui and fullscreen are widely supported in current browsers; the newer values are limited to some platforms, so check a compatibility table before using them.
Related
:fullscreenโ styles the fullscreen element@mediaโ the at-rule- Lesson: Media Queries